Hi
In a form say form2's load event I will retrive some information and based on the condition I will add that data as a row to the dgv or an empty row if the condition fails as below.
private void form2_load(object sender, EventArgs e)
{
if (list6.ElementAtOrDefault(i) == "09:00:00")
{
String[] row = { "9.00-9.30 AM", "", list2.ElementAtOrDefault(i), list3.ElementAtOrDefault(i), list8.ElementAtOrDefault(i), "",......, };
dataGridView1.Rows.Add(row);
i++; ;
}
else
{
String[] row = { "9.00-9.30 AM", "", "", "", "", "", "", "", "", "", "", "", "", "", "" };
dataGridView1.Rows.Add(row);
}
if (list6.ElementAtOrDefault(i) == "09:30:00")
{
String[] row = { "9.30-10.00 AM", "", list2.ElementAtOrDefault(i), list3.ElementAtOrDefault(i), list8.ElementAtOrDefault(i), "", ......., };
dataGridView1.Rows.Add(row);
i++; ;
}
else
{
String[] row = { "9.30-10.00 AM", "", "", "", "", "", "", "", "", "", "", "", "", "", "" };
dataGridView1.Rows.Add(row);
}
if (list6.ElementAtOrDefault(i) == "10:00:00")
{
String[] row = { "10.00-10.30 AM", "", list2.ElementAtOrDefault(i), list3.ElementAtOrDefault(i),..................,};
dataGridView1.Rows.Add(row);
i++; ;
}
else
{
String[] row = { "10.00-10.30 AM", "", "", "", "", "", "", "", "", "", "", "", "", "", "" };
dataGridView1.Rows.Add(row);
}
}
In another form say form7's load event I want do delete the dgv rows of form2. How can I delete the rows that are present in form2 from form7
please help
Thanks
Loading
Kirtan PatelPosted Jun 9, 2009, 9:11 AM
in Form 7 in buttons Click Event Write code like Below
Kirtan PatelPosted Jun 10, 2009, 8:45 AM
sachi vasishtaPosted Jun 10, 2009, 2:55 AM
FormCollection fc=Application.OpenForms; // gets the collection of forms
foreach(Form f in fc) // looping for forms
{
if(f.Name=="Form2") // if the selected form is Form2
{
((Form2).(f)).Deleterows(); // what this does???
}
}