Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Combox propertyies in .NET

Posted on 2013-06-03
2
Medium Priority
?
292 Views
Last Modified: 2013-06-03
Hi Experts,
I have three comboboxes in my .NET application.  I want to name the comboboxes the same (i.e. cboTEST), and give each a different INDEX number (i.e.  cboTEST(0), cboTEST(1), and cboTEST(3)).  How can I do this in .NET?  I used to be able to do this in VB6.

Thanks in advance,
mrotor
0
Comment
Question by:mainrotor
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 39217150
You don't need control arrays in VB.Net.

The Index in VB6 allowed you to identify which control fired the event.  In VB.Net, you can wire up multiple controls to the same handler and then use the "sender" parameter to determine which control fired the event.

You can do this by adding more than one control to the "Handles" clause at the end of the handler like this:
    Private Sub ComboBoxes_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged, ComboBox2.SelectedIndexChanged, ComboBox3.SelectedIndexChanged
        Dim cb As ComboBox = DirectCast(sender, ComboBox)
        If cb.SelectedIndex <> -1 Then
            Debug.Print(cb.Name & " --> " & cb.SelectedIndex & ": " & cb.SelectedItem)
        End If
    End Sub

Open in new window

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 39217380
BTW...welcome to the world of .Net!  =)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question