Solved

Get Selected Index from ComboBox

Posted on 2009-03-31
3
441 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

Industry Leaders: 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

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…

740 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