A very specific question here. Would like to make use of DoubleClick event, when someone clicks the empty cell before every row.
Made the method and assigned it to DoubleClick event. It works too.
Now am loading data from the database in the DataGridView; how can I get the value of Cell[0] of respective row on which I double clicked. I'd like to get the int value there in Cell[0] so I can show the detailed form of that entry.
With this, yes, my question is also about kindly sharing how the value transferring works between methods, forms and such helpful examples.
Thank you.
How to > DataGridView > Technical Logic > Part 2
Re: How to > DataGridView > Technical Logic > Part 2
Code: Select all
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
MessageBox.Show(dataGridView1.CurrentRow.Cells[0].Value.ToString());
}
Re: How to > DataGridView > Technical Logic > Part 2
How can we pass this value to a new form?
I have two ideas, not sure if they are correct.
1. To instantiate the new form and assigning this value to a public variable to access there.
2. Assign the value to an static variable.
Are they correct? Any other suitable options? Most preferable please?
I have two ideas, not sure if they are correct.
1. To instantiate the new form and assigning this value to a public variable to access there.
2. Assign the value to an static variable.
Are they correct? Any other suitable options? Most preferable please?
Re: How to > DataGridView > Technical Logic > Part 2
The controls on a form are private, visible only for that form by design. So better to store it in a public variable.