Solved

Combox propertyies in .NET

Posted on 2013-06-03
2
284 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

631 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