Solved

Get Selected Index from ComboBox

Posted on 2009-03-31
3
438 Views
Last Modified: 2012-05-06
Hi EE,

I am trying to get the selected id for a combobox.

I have tried ... cC.StateID = Me.cboState.ValueMember(Me.cboState.SelectedIndex)  but it is an error.
What I need is the value that is saved in there from the code below.

Thanks

Dim ds As New DataSet
 

        If DatabaseToUse() = BizObjs.DBType.Access Then

            'Access Database

            Dim cFields As New cFieldTableNames

            cFields.ComboTable = msTblName

            SelectStr = cFields.ReturnComboString()

            Dim dc As New OleDb.OleDbConnection(ConnectionString)

            Dim da As New OleDb.OleDbDataAdapter(mSelectStr, dc)
 

            Try

                da.Fill(ds)

                dc.Close()
 

                cnt.DataSource = ds.Tables(0)

                cnt.DisplayMember = cFields.SendToCorrectFieldProcedure(3)

                cnt.ValueMember = cFields.SendToCorrectFieldProcedure(1)

'Returns the field Name of "StateID"
 

            Catch ex As Exception
 

                MessageBox.Show(ex.Message)

                Throw ex
 

            Finally

                dc.Close()

                da.Dispose()

            End Try

        End If

Open in new window

0
Comment
Question by:Sheritlw
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 24034777
Have you tried
Me.cboState.SelectedValue ?
0
 

Author Comment

by:Sheritlw
ID: 24034839
Hi Jpaulino,

No I didn't try... I guess that just seemed so simple.  
I know after many years programming in VB 5 - VB 6, .Net seems like it requires a lot of code.
I always used sql server as a backend, until now and the backend handled everything.
In .Net it seems like you have to write a lot of code in the front end, no matter what.
Thanks,
Sheri
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24034849
Is just a matter of time and you get use to it. You will love in the end :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Check if number is currency 15 31
Get String split 5 46
Get Top Visible Row of Datagridview 6 27
Variable Event ? 3 20
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

914 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now