Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Combobox, SelectedIndexChanged Get Index

Posted on 2016-10-29
2
Medium Priority
?
92 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 2000 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 83

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

Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

Question has a verified solution.

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

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

730 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