Click here to Skip to main content
15,898,374 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hay All
I have a problem, please help me. From the database have I the Field in my Combobox with DataBindings:
C#
sqlConnection1.Open();
dt = new DataTable();
sqlDataAdapter1.Fill(dt);
BindingSource bs = new BindingSource();
bs.DataSource = dt.DefaultView;
Combobox1.DataSource = bs;
Combobox1.DisplayMember = "Model";
Combobox1.ValueMember = "Model";
txtPrice.DataBindings.Add("Text", bs, "Price");

It's work fine...
When I select the first row, within the method SelectedIndexChanged thw Current BindingSource row is null. Then if I select the second row the current row is the previous one, the first until the SelectedIndexChanged is returned.
Is there a way to get the current row while in SelectedIndexChanged?

EDIT - Moved from answer

please help | :(( (((((((( ((((((((((((((((((((((((((((((((
Posted
Updated 28-Jul-11 6:56am
v3
Comments
thatraja 28-Jul-11 12:58pm    
Something not clear. what do you mean the row or current row here? Also include the other event's code in your question so that you can get solution quickly. Run forrest run.
walterhevedeich 28-Jul-11 20:12pm    
I have deleted your other question. I advice you not to repost questions as this will only cause confusion.

1 solution

The SelectedIndexChanged event is fire prior to databinding, so as you have noticed the Current property is always 1 change behind. If you want to find out what value is selected in the Combobox1 when the SelectedIndexChanged event is fired you need to check out the SelectedItem, SelectedValue, and SelectedText properties on Combobox1 to get the value that has just been selected in the Combobox.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900