Hi all,
How can I check if a datagrid contains column "x" and column "x" is visible?
All I have so far is below.
if (Dgv.Columns.Contains("Address") & ....
Thanks
Hi all,
How can I check if a datagrid contains column "x" and column "x" is visible?
All I have so far is below.
if (Dgv.Columns.Contains("Address") & ....
Thanks
You can test the column visibility using the Visible
property:
if (column.Visible)
{
// Do Stuff
}
This will tell you if the column should be displayed.
You can get the column via this call if you know the index:
DataColumn column = dGV.Columns[index];
If the column is displayed but off the screen I don't know how you'd test for that.
Loop through the columns, checking the heading (I assume that's what you're looking for) and the Visible property.
The straightforward method:
if (dgv.Columns.Contains("Address") && dgv.Columns["Address"].Visible)
{
// do stuff
}