How do I retrieve the value from a combo box?


Author
Message
Robert Carl Johnson
Robert Carl Johnson
StrataFrame Novice (64 reputation)StrataFrame Novice (64 reputation)StrataFrame Novice (64 reputation)StrataFrame Novice (64 reputation)StrataFrame Novice (64 reputation)StrataFrame Novice (64 reputation)StrataFrame Novice (64 reputation)StrataFrame Novice (64 reputation)StrataFrame Novice (64 reputation)
Group: Forum Members
Posts: 48, Visits: 130
Hi all. I am a little confused regarding lists and combo box's I guess. I looked at the tutorial and but I don't see how you "get" the values from the selected record from the list or combo box. I have a combo box set up on my custom password form with two columns, FullName and ID: {0},{1} respectivly. Now, the value I need to retrieve is the ID value. I tried placing some code in the events SelectedIndexChanged with no joy. I'm not sure of the arguments to use to get my value. Can someone please help me. ID is an Integer.



The second part: What I'm trying to do is, after getting the ID number is send that number to my function and have the funtion run a select to get the employee record and return to me the password. I will then assign it to my var EmpPW as seen below. cboFullName is the name of the Combobox and I'm guessing at .ValueMember



Am I wrong or right? If incorrect then how do I do this?



My code to send to my Function is: EmpPW = Me.EmployeeBO1.GetEmpoyeeByID(txtFullName.ValueMember.



Thanks in advance



Robert

(New to .Net)
Reply
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
If you are using the population data source settings on the control, then you specify the value member.  It might help if you just look into how a combo box natively works when using a DataSource as this is really all that we do behind the scenes.  We populate based on your PopulationDataSourceSettings property or Enumeration then create an ADO.NET data table that has two fields...Description and Value.  The description is what you see that is defined in the Display Member Format String field and the Value is set to the Value Member.

All Lists and Combos have a property called SelectedValue which gives you the "selected' value of the control.  Likewise if you want to get the display value you can just reference the Text property.

For example:

Dim lnValue As Integer = CType(MyCombo.SelectedValue, Integer)

or

Dim lcDisplayText As String = MyCombo.Text

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search