My datagrid show a table from my sqlBd. I add a textBox for each column that for show each rows.
This is my code:
private void CustomerViewToolStripMenuItem_Click(object sender, EventArgs e)
{
BindingSource Clients_bs = new BindingSource();
SqlConnection con = new SqlConnection(dc.Con);
con.Open();
da.SelectCommand = new SqlCommand("SELECT * FROM Clients", con);
da.Fill(dt);
con.Close();
dgCustomers.DataSource = dt;
Clients_bs.DataSource = dt;
txtBoxIdCustomers.DataBindings.Add(new Binding("Text", Clients_bs,"id_Client"));
txtBoxFullName.DataBindings.Add(new Binding("Text", Clients_bs, "prénom_Nom"));
txtBoxAddress.DataBindings.Add(new Binding("Text", Clients_bs, "adresse"));
txtBoxCity.DataBindings.Add(new Binding("Text", Clients_bs, "ville"));
txtBoxProvince.DataBindings.Add(new Binding("Text", Clients_bs, "province"));
txtBoxPostal.DataBindings.Add(new Binding("Text", Clients_bs, "code_Postal"));
txtBoxPhone.DataBindings.Add(new Binding("Text", Clients_bs, "numéro_Teléphone"));
}
That fill my dataGrid like my table in sql, and my txtbox’s shows the first row only whit the cursor pointing on the first row in my dataGrid.
I want to move the cursor of the data grid on the second row and show txtbox’s bind automatically on the second row ….
I can make whit a button previous and next, but not whit the cursor…
Thank’s for helping me!
instead of this:
do this:
then it should work as the TextBoxes and the Grid have the same BindingSource 😉
Edit:
and also, please, instead of this:
do this: