N
Nevyn Twyll
I have a windows form.
It fetches some data that it keeps in a Dataset (in a property).
I want to bind a grid to that datasource, and have 2 textboxes (they could
also be labes if need be, but textboxes would be better) on the form that
display (read-only) the contents of a couple of text fields.
The only thing I can really get to happen is to have the textboxes display
the data from the first row of the dataset, but not change .
Here's a sample of my code:
// Fetch the data and name the table
DataSet ds = sqlconnection.ExecuteDataSet(...)
ds.Tables[0].TableName = "MyTable";
// Bind the datagrid
myDataGrid.DataMember = "MyTable";
myDataGrid.DataSource = ds;
// Bind the textbox?
txtMyTextBox.DataBindings.Add(new Binding("Text", ds,
"MyTable.MyTextField"));
So I guess my question might be: how do I tell (get an event handler, etc.)
when the current row in the datagrid changes, and which row it is. Is there
anything like in asp.net datalists?
Thanks for the help!
It fetches some data that it keeps in a Dataset (in a property).
I want to bind a grid to that datasource, and have 2 textboxes (they could
also be labes if need be, but textboxes would be better) on the form that
display (read-only) the contents of a couple of text fields.
The only thing I can really get to happen is to have the textboxes display
the data from the first row of the dataset, but not change .
Here's a sample of my code:
// Fetch the data and name the table
DataSet ds = sqlconnection.ExecuteDataSet(...)
ds.Tables[0].TableName = "MyTable";
// Bind the datagrid
myDataGrid.DataMember = "MyTable";
myDataGrid.DataSource = ds;
// Bind the textbox?
txtMyTextBox.DataBindings.Add(new Binding("Text", ds,
"MyTable.MyTextField"));
So I guess my question might be: how do I tell (get an event handler, etc.)
when the current row in the datagrid changes, and which row it is. Is there
anything like in asp.net datalists?
Thanks for the help!