내 양식에서 텍스트 상자의 이벤트를 처리하는 방법을 알고 있습니다. 그러나 30 개의 텍스트 상자를 사용하기 때문에이 코드를 더 짧게하고 싶습니다. 다음을 사용하는 것은 비효율적입니다.하나의 핸들러에서 모든 텍스트 이벤트 처리
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged, TextBox3.TextChanged, TextBox4.TextChanged, TextBox5.TextChanged, TextBox6.TextChanged, TextBox7.TextChanged, TextBox8.TextChanged, TextBox9.TextChanged, TextBox10.TextChanged
Dim tb As TextBox = CType(sender, TextBox)
Select Case tb.Name
Case "TextBox1"
MsgBox(tb.Text)
Case "TextBox2"
MsgBox(tb.Text)
End Select
End Sub
처리기를 단축 할 방법이 있습니까?
나는 [질문]이라고 생각합니다. (http://stackoverflow.com/questions/15336379/get-text-inside-buttons-when-pressed- 어제는 using-only-one-event-handler를 사용했다. –
내가 가장 단축 된 버전을 찾고 있는데^_^ – conquistador