I'm using the following code to set a bunch of DataGridViewRow
elements to be invisible. The rule I am using is to check the associated datasource for a boolean flag. If the flag is true, the row will be displayed. If not, it will be invisible.
The following code works; however, it does so by consuming quite a bit of time:
CurrencyManager currencyManager = (CurrencyManager)BindingContext[dataGridView.DataSource];
currencyManager.SuspendBinding();
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (!objectList.list[row.Index].Selected)
{
row.Visible = false;
}
}
currencyManager.ResumeBinding();
Does anyone have a better solution? The longer the list of objects I have to go through, the longer this process takes, naturally. I cannot set a range of cells because the boolean values may not be contiguous.