Welcome Guest!
 VB Helper Q & A
 Previous Message All Messages Next Message 
RE: Indexing controls on windows forms  vic_ng-@xs4all.nl
 Apr 17, 2010 03:02 PDT 

Reinhard Neuwirth wrote:
VB6.0 provided for controls to be grouped in group boxes and to be
indexed, so that clicking any one of the controls invoked a single click

handler in which actions could be defined by selecting on the index.
This feature seems to have disappeard from VB2010. Looping through every

control in a group box's control collection is possible, but I have been

unable to assign a single click handler for the whole collection. I'd be

grateful for ideas.

Hi Jessica,

The group box still provides one-only selection functionality for
RadioButtons, but apart from that there is a general way for coding
events for multiple controls in VB.Net.

Shift-select the controls in the Designer and then click the
lighting-bolt button at the top of the Properties window. You'll get a
list of all the events. Double-click an event, and the boilerplate code
for that event appears in the code window. It has multiple handles
clauses, so the code will work for all the selected controls. For

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object,
                                        ByVal e As System.EventArgs) _
Handles RadioButton3.CheckedChanged,   RadioButton2.CheckedChanged,      
End Sub

You can also select individual controls by casting the sender argument
to the control type. Alternatively you can change "sender As
System.Object" to "sender As RadioButton" or whatever they are.

hope this helps, Vic
 Previous Message All Messages Next Message 
  Check It Out!

  Topica Channels
 Best of Topica
 Art & Design
 Books, Movies & TV
 Food & Drink
 Health & Fitness
 News & Information
 Personal Finance
 Personal Technology
 Small Business
 Travel & Leisure
 Women & Family

  Start Your Own List!
Email lists are great for debating issues or publishing your views.
Start a List Today!

© 2001 Topica Inc. TFMB
Concerned about privacy? Topica is TrustE certified.
See our Privacy Policy.