sachi vasishta

sachi vasishta

  • NA
  • 252
  • 0

how to remove the rows of datagridview of one form from another form

Jun 9 2009 4:38 AM


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

Answers (3)