How to remove the column in Data Grid View using C#

  • Thread starter Thread starter kvg sasi
  • Start date Start date
K

kvg sasi

Guest
Hi all,

Good Day! I am using C# in Microsoft Visual Studio 2008. In this I am viewing Remote Data Base tables in DataGridView Control. In this DataGridView Control i am viewing different Tables. Tables have different columns. so based on table columns i have to remove extra columns in Data Grid View. I tried it. but it is not working. Can you please give me an idea to solve it.

And my code is :

bool blank = true;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
blank = true;

for (int i = 0; i <= row.Cells.Count - 1; i++)
{
if (row.Cells(i).Value != null && !string.IsNullOrEmpty(row.Cells(i).Value))
{
blank = false;
break;
}
}
if (blank)
{
if (!row.IsNewRow)
{
dataGridView1.Rows.Remove(row);

}

}
}





Thanks & Regards Sasi ................. Go Green

Continue reading...
 
Back
Top