I'm a C# beginner and like your input!
I have a datagridview and want to do some stuff with the selected rows. I dont want to place all the tasks in one large function..... I'd like to split it up in seperate task-functions. I'm using 'r' to have the index of the selected line. But how do I get that index 'r' to be used in the functions do_stuff1, do_stuff2,....?
Or am I going about this the wrong way?
private void button1_Click_1(object sender, EventArgs e)
{
foreach (DataGridViewRow r in dataGridView1.SelectedRows)
{
do_stuff1();
do_stuff2();
do_stuff3();
}
}
private void do_stuff1()
{
//do stuff1 with selected row r
}
...
All help kindly appreciated!
This comment from @Serg helped me out:
just pass
r
as parameter: declare function asprivate void do_stuff1(DataGridViewRow r)
and then call asdo_stuff1(r);
Thanks to @Serg and @ZoharPeled