Hello
I hope someone can help a C# newstarter.
I have a DataGrid where I fill in my data via a DataSet.
Now I created a method which should open a new form once I doubleclick the cell content of my DataGrid.
private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
i = e.RowIndex;
j = e.ColumnIndex;
string rowtest = "";
string conString = "Data Source=localhost\\TESTDB;Initial Catalog=nordwind;Integrated Security=SSPI";
conn = new SqlConnection(conString);
conn.Open();
ds1 = new DataSet();
adapter = new SqlDataAdapter("Select * from Artikel", conn);
adapter.Fill(ds1, "Artikel");
...
}
What I want is to display the value of each column from my DataGrid at position "i" in a "TextBox".
Lets say my DataGrid has two columns. Column "A" has the value "blah1" and column "B" the value "blah2" @ RowIndex i.
"blah1" should be displayed in TextBox1, and "blah2" in TextBox2, once I doubleclick the row.. (or rather Cell, since I don't know any event, which would mark the whole row).
I guess this shouldn't be so hard, having the RowIndex.. but it seems I am to stupid to figure this out.
I have been struggling with this simple issue for two days now.. read several tutorials, but none seemed to cover my problem.
Any small hint would be welcome.
I hope someone can help a C# newstarter.
I have a DataGrid where I fill in my data via a DataSet.
Now I created a method which should open a new form once I doubleclick the cell content of my DataGrid.
private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
i = e.RowIndex;
j = e.ColumnIndex;
string rowtest = "";
string conString = "Data Source=localhost\\TESTDB;Initial Catalog=nordwind;Integrated Security=SSPI";
conn = new SqlConnection(conString);
conn.Open();
ds1 = new DataSet();
adapter = new SqlDataAdapter("Select * from Artikel", conn);
adapter.Fill(ds1, "Artikel");
...
}
What I want is to display the value of each column from my DataGrid at position "i" in a "TextBox".
Lets say my DataGrid has two columns. Column "A" has the value "blah1" and column "B" the value "blah2" @ RowIndex i.
"blah1" should be displayed in TextBox1, and "blah2" in TextBox2, once I doubleclick the row.. (or rather Cell, since I don't know any event, which would mark the whole row).
I guess this shouldn't be so hard, having the RowIndex.. but it seems I am to stupid to figure this out.
I have been struggling with this simple issue for two days now.. read several tutorials, but none seemed to cover my problem.
Any small hint would be welcome.
Last edited: