|
-
Mar 31st, 2006, 02:34 AM
#1
Thread Starter
Hyperactive Member
combobox problem
Hi,
I use a combobox to show username, the property
DisplayMember is the username and ValueMember is the userID.
In the combobox's SelectedIndexChanged event, I do some checking by accessing the SelectedValue property.
When I run my program, during initialize stage, I found that the SelectedValue property will return a {System.Data.DataRowView} instead of the actual value, and cause my program to fail.
Is there anything I need to take care? Currently, I just use a boolean flag to control the checking inside the event.
Thx!
-
Apr 5th, 2006, 08:44 PM
#2
Re: combobox problem
It sounds like you're assigning the control's DataSource property before setting the DisplayMember and ValueMember properties.
When you assign the DataSource the control is populated and the SelectedIndexChanged event is triggered.
If you set the DataSource property after setting the DisplayMember and ValueMember properties you wont have that problem:
VB Code:
ComboBox1.DisplayMember = "Username"
ComboBox1.ValueMember = "UserId"
ComboBox1.DataSource = table
Regards,
- Aaron.
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
|