Live Chat Icon For mobile
Live Chat Icon

In VB6, I used control arrays to have a common handler handle events from several controls. How can I do this in Windows Forms

Platform: WinForms| Category: from VB6

You can specify events from different controls be handled by a single method. When you define your handler, you can list several events that are to be handled by listing them in the Handles argument. This statement handles three different textbox’s TextChanged event.

	 Private Sub TextsChanged(ByVal sender As System.Object, _
		ByVal e As System.EventArgs) _
		Handles TextBox1.TextChanged, TextBox2.TextChanged, TextBox3.TextChanged

In the TextsChanged handler, you may need to identify the particular control that fired the event. This sender parameter holds the control. You can use it with code such as:

	Dim eventTextBox as TextBox = sender

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.