Posted By: jogisarge | Dec 13th, 2008 @ 1:42 AM
page 1 of 1
Comments: 2 | Views: 1074

Hi,

i want to show in a textbox the value from a selected row in my datagridview.

DataSet dsHersteller = new DataSet();
BindingSource bsHersteller = new BindingSource();

dsHersteller = herstellermanager.GetList(); // - delivers a dataset
bsHersteller.DataSource = dsHersteller.Tables["producer"];
bsHersteller.Sort = "producer_id";
dgvHersteller.DataSource = bsHersteller.DataSource;

tbxHerstellerNr.DataBindings.Add("Text", bsHersteller, "producer_id");

Now, when i start the app, the value of the textbox is the first row in datagridview.
If i select another row, nothing changes in my textbox.

I thougt, i bound the textbox to the grid ??

Can anybody give me tips for my problem ?

By jogi

jh71283
jh71283
Throw new System.Beverage. OutOfCoffeeException​()
From what I can see, you are not binding the data grid to the bindingsource, you are binding it to the Bindingsource's datasource, effectively bypassing the bindingsource.


try using dgvHersteller.DataSource = bsHersteller
page 1 of 1
Comments: 2 | Views: 1074
Microsoft Communities