I am using a similar query to load data from 100ish databases into a grid based on a drop down picker. The query returns roughly 20 columns, but only about 5 columns are ever used in each database. I would like to suppress/hide the empty columns. Does the DataGrid component have an easy way to do this?
As a note, All of the data is being loaded into a List of DataObjects with each of the properties, then bound to the grid. A property like "HideIfEmpty = True/False" would be ideal
in a desktop app, I use something like this:
foreach (DataGridViewColumn clm in grdView.Columns)
{
bool notAvailable = true;
foreach (DataGridViewRow row in grdView.Rows)
{
if (row.Cells[clm.Index].Value != null && !string.IsNullOrEmpty(row.Cells[clm.Index].Value.ToString()))
{
notAvailable = false;
break;
}
}
if (notAvailable)
{
grdView.Columns[clm.Index].Visible = false;
}
}
But it would be much cleaner if there was a native way to do it