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 PatelRank #292 · 8.6K reputationPosted Jun 9, 2009, 5:11 AM EDT
in Form 7 in buttons Click Event Write code like Below
private void button1_Click(object sender, EventArgs e) { //Delete Row of Form2 FormCollection fc = Application.OpenForms; foreach (Form f in fc) { if (f.Name == "Form2") { ((Form2)(f)).DeleteRow(); } } }sachi vasishta180 reputationPosted Jun 9, 2009, 10:55 PM EDT
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???
}
}
Kirtan PatelRank #292 · 8.6K reputationPosted Jun 10, 2009, 4:45 AM EDT
private void button1_Click(object sender, EventArgs e) { //Delete Row of Form2 FormCollection fc = Application.OpenForms; foreach (Form f in fc) { if (f.Name == "Form2") { // Caste f in Form2 So That we can Get DeleteRow() Method in Intellisence List and Invoke DeleteRow Method of the Founded Form2 's Instance ((Form2)(f)).DeleteRow(); } } }