What you're talking about is handling the 55 different events with one method. The answer is the Handles clause of the event handler method.
When you double-click a control in the designer, it will generate a method to handle the default event, e.g. the TextChanged event of a TextBox. If you double-click a control named TextBox1, you'll see this code generated:
VB.NET:
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
End Sub
Note the Handles clause there. That specifies which events are handled by that method. You can manually edit that Handles clause if you want, e.g.
VB.NET:
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
End Sub
but I wouldn't recommend that for 55 controls. The way you should normally do it is first select all the controls in the designer, then open the Properties window and click the Events button. That will list all the events for the selected item(s) and you can then double-click an event to generate an event handler. If you have selected multiple controls, they will all be included in the Handles clause. You can also use the drop-down for any event to select an existing event handler and have that event for that control added to the Handles clause. I would suggest that, if you use a single method to handle multiple events, you change the name to reflect that, e.g. TextBoxes_TextChanged instead of TextBox1_TextChanged.
It's something like talking to a therapist. Much of the time, the therapist doesn't actually do anything but give you someone to talk to and hearing yourself say the words helps you work out what to do about the problem. Often times, describing a problem in a forum post or the like actually clarifies the issue in your mind and makes you better able to find a solution for yourself, e.g. with better search keywords.
Thank you for clarifying my terminology... I have so much to learn. And thank you for the steps on creating the Method by clicking the Events button in the Properties. That saves a lot of copy/paste/edit
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.