Solved

Get Selected Index from ComboBox

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

706 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

19 Experts available now in Live!

Get 1:1 Help Now