Formãéããæã ãValidatingã¤ãã³ãå ã§ã®æ¤è¨¼ããããæ¹æ³
ãã©ã¼ã ã«è²¼ãä»ããã³ã³ããã¼ã«ã®Validatingã¤ãã³ããã³ãã©å ã§
if(!this.CauseValidation && this.ActiveControl == å ã®ã³ã³ããã¼ã«) { return; } if (!this.ActiveControl.CausesValidation) { return; }
ã¨ããã
Ããã¿ã³ã§éããæã¯ãå
ã®ã³ã³ããã¼ã«ãã¢ã¯ãã£ããªã¾ã¾ãªã®ã§ãActiveControlãå
ã®ã³ã³ããã¼ã«ã ã£ããæããã
æ¬æ¥ãActiveControlã®CauseValidationãfalseã®æã¯ãValidatingã¤ãã³ããçºçããªãã¯ããªã®ã§ãValidatingã¤ãã³ãå
ã§ãActiveControlã®CauseValidationãfalseã§ããäºã確èªãããreturnã§æããã
ã«ã¹ã¿ã ã³ã³ããã¼ã«ã®å®è£ æã«ã¯ãOnValidatingããªã¼ãã©ã¤ããã¦ãbase.OnVvalidating()ãå¼ã¶ã¾ãã«
System.Windows.Forms.Control 親ã³ã³ããã¼ã« = this.Parent; while (親ã³ã³ããã¼ã« != null) { if (親ã³ã³ããã¼ã« is System.Windows.Forms.Form) { if (親ã³ã³ããã¼ã«.CausesValidation) { break; } if ((親ã³ã³ããã¼ã« as System.Windows.Forms.Form).ActiveControl == this) { return; } if (!(親ã³ã³ããã¼ã« as System.Windows.Forms.Form).ActiveControl.CausesValidation) { return; } } 親ã³ã³ããã¼ã«= 親ã³ã³ããã¼ã«.Parent; }
ã¨ããã
åºæ¬çã«ã¯ããã©ã¼ã ã«è²¼ãä»ããå ´åã¨åãã§ã追å ãããå®è£
ã¯Formã³ã³ããã¼ã«ãè¦ã¤ããã¾ã§è¦ªãé¡ãäºã