How do I retrieve the value from a combo box?


Author
Message
Robert Carl Johnson
Robert Carl Johnson
StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 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)
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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

Robert Carl Johnson
Robert Carl Johnson
StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)
Group: Forum Members
Posts: 48, Visits: 130
Boy do I feel dumb. I didn't think to check normal behavior... I just figured it would be a SF property... lol. Well that teaches me a lesson.



Thanks for the reply Trent,



Regards,



Robert
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Don't feel bad. I remember a bit O'head banging over this myself (among other simple things) BigGrin
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Boy do I feel dumb. I didn't think to check normal behavior.

Don't feel this way at all!!!  I am glad that you asked as at least you now know how it works.  If you don't ask you don't learn Smile  Please don't let this deter you from posting questions in the future!!! Smile

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