Solved

Combobox, SelectedIndexChanged Get Index

Posted on 2016-10-29
2
56 Views
Last Modified: 2016-10-30
I have a combo-box with static data and when I select an item in the combobox I want to return the Index into the Array.

 Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        If (String.IsNullOrEmpty(ComboBox1.Text)) Then
            MessageBox.Show("No Item is Selected")

        Else
            Label5.Text = " You have Selected :" + ComboBox1.TabIndex.ToString
        End If

    End Sub

Open in new window


ComboBox with Array
 'ComboBox1
        '
        Me.ComboBox1.FormattingEnabled = True
        Me.ComboBox1.Items.AddRange(New Object() {"Has The Screen Got Wet in the last 24 Hours", "Is the Screen of the device cracked", "Is your Screen Slow and crashing?", "Is your Touch Screen not responding", "Do you have Sufficient Funds in your account to send Text Message", "Are you able to recieve and send text messages", "Do you have sufficient funds in your account", "are you connected to WIFI or have sufficient funds to use data"})
        Me.ComboBox1.Location = New System.Drawing.Point(34, 186)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(470, 21)
        Me.ComboBox1.TabIndex = 17
        '

Open in new window

0
Comment
[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 Comments
 
LVL 28

Accepted Solution

by:
Ark earned 500 total points
ID: 41865649
ComboBox1.TabIndex.ToString will return what u'r asking for - TabIndex which is 17 for combo1.
If you need item index (integer), use ComboBox1.SelectedIndex (-1 means nothing selected).
Since all objects in your combo are strings, you can use ComboBox1.SelectedItem.ToString to get selected item text. You can get same string using ComboBox1.Text property since SelectedIndexChanged fired AFTER ComboBox change it's text to one you choose.
0
 
LVL 80

Author Closing Comment

by:David Johnson, CD, MVP
ID: 41865668
Thank you it was the ComboBox1.SelectedIndex that I couldn't find when break pointing the code
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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

756 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