|
-
Jul 18th, 2008, 06:44 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2005] combobox databinding
im trying to bind dataset at runtime to combobox with the valuemember and displaymember column assign. im playing this code
vb Code:
ComboBox1.DataSource = ds.Tables(0)
ComboBox1.ValueMember = "pk_clientID"
ComboBox1.DisplayMember = "clientname"
to make the name appear in the combobox item list and on the other hand the ID will be use for details referencing.
tnx
-
Jul 18th, 2008, 08:08 AM
#2
Re: [2005] combobox databinding
-
Jul 18th, 2008, 10:41 AM
#3
Thread Starter
Fanatic Member
Re: [2005] combobox databinding
oops why did i post that unfinish. anyway here the remaining part:
vb Code:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged MessageBox.Show(ComboBox1.ValueMember) End Sub
and this return the string "pk_clientID" regardless of what ive selected in the combobox item its return the same value.
Last edited by jlbantang; Jul 18th, 2008 at 10:59 AM.
-
Jul 18th, 2008, 12:37 PM
#4
Re: [2005] combobox databinding

Yes, the valuemember only gets/sets the field in the datasource to use for the value property. To get the value that is selected use combobox1.selectedvalue.
 I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Jul 18th, 2008, 12:40 PM
#5
Re: [2005] combobox databinding
i think you are looking for
Code:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
MessageBox.Show(ComboBox1.SelectedValue)
End Sub
__________________
Rate the posts that helped you 
-
Jul 18th, 2008, 02:58 PM
#6
Thread Starter
Fanatic Member
Re: [2005] combobox databinding
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|