Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1145
Header checkbox - checked appearance only showing on visible columns until...
posted

UltraWinGrid v9.2.  The following code borrowed from these forums loops through the columns collection and sets the header check state to checked or unchecked.  The problem is this only happens (graphically) on visible (on screen, not hidden) columns, however if you scroll right and view all of the columns, this method then checks or unchecks all columns whether they are visible on screen or not.  In other words, after the grid loads for the first time the off screen columns will not receive the visibly checked appearance until you have scrolled and viewed them on screen at least one time and run the method again.  The code, however knows that each column is checked regardless of appearing unchecked, so this is a wierd graphics thing.  Adding a myGrid.Refresh() and/or myGrid.Update() did not help.   Is there a way to have the checked appearance visible without having to first view the columns?

private void myGrid_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e)
{
    UltraGridColumn c = e.Column;
    CheckState newCheckState = c.GetHeaderCheckedState(e.Rows);

    switch (newCheckState)
    {
        case CheckState.Checked:
            foreach (UltraGridColumn siblingColumn in c.Band.Columns)
            {
                if (siblingColumn == c)
                    continue;

                siblingColumn.SetHeaderCheckedState(e.Rows, true);
            }

            break;
        case CheckState.Unchecked:
            foreach (UltraGridColumn siblingColumn in c.Band.Columns)
            {
                if (siblingColumn == c)
                    continue;

                siblingColumn.SetHeaderCheckedState(e.Rows, false);
            }
            break;
        default:
            break;
    }
}

Parents Reply Children
No Data