Solved

Combox propertyies in .NET

Posted on 2013-06-03
2
283 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

751 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