textBoxArray[i].TextChanged += new EventHandler(_TextChanged);
の働きを教えて頂けないでしょうか?
テキストボックスに入力された値を取得するプログラムを作成しております。
以下作成途中のプログラムとなります。
// textBoxArrayインスタンスを生成する。 TextBox[] textBoxArray = new TextBox[3]; // textValuesインスタンスを生成する。 string[] textValues = new string[3]; private void Form1_Load(object sender, EventArgs e) { // textBoxArrayにテキストボックス情報を代入 textBoxArray[0] = a_tb; textBoxArray[1] = b_tb; textBoxArray[2] = c_tb; for (int i = 0; i < 3; i++) { textBoxArray[i].TextChanged += new EventHandler(_TextChanged); } } private void _TextChanged(object sender, EventArgs e) { for (int i = 0; i < textBoxArray.Length; i++) { // 指定した複数の Object インスタンスが同一インスタンスかどうかを判断します。 if (Object.ReferenceEquals(sender, textBoxArray[i])) { textValues[i] = (textBoxArray[i].Text); } } for (int i = 0; i < textBoxArray.Length; i++) { // textboxが NULL・空欄であるか判断 if(textValues[i] == null || textValues[i] == string.Empty) { return; } } ・ ・ ・
回答1件
あなたの回答
tips
プレビュー