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
  • 6158
    Suggested Answer
    Offline posted

    Hello,

    Let me see if I understand your situation correctly. If there are columns which have never been scrolled into view, and you check one of the header checkboxes, the checkboxes for the out of view columns are do not appear to be in sync with the underlying values once the columns are scrolled into view.

    Is the code which is supposed to check the out of view columns being triggered by the user clicking on a visible header checkbox, programmatically calling SetHeaderCheckedState(), or by some other method?

    What are the HeaderCheckBoxSynchronization set to for all the columns? 

    If you are calling SetHeaderCheckedState() on your own, what are you passing in for the Rows parameter?

    When the HeaderCheckBoxSynchronization resolves to Band, the CheckState value for the column is stored on the Band. However, when it resolves to RowsCollection or None, the value is stored on the provided RowsCollection. When using RowsCollection or None, if null is passed to the SetHeaderCheckState(), the value cannot be set.

    What build of NetAdvantage 2009 Volume 2 are you using? It may be beneficial to installed the latest service release for the volume to see if this behavior is already addressed.

    How to get the latest service release - Infragistics Community

    Note that the code you provided has been modified from my original posting which will cause all the column checkboxes to be checked/unchecked no matter which one is clicked. Additionally, since AfterHeaderCheckStateChanged event fires for each checkstate that changes, you will loop through the column numerous times unintentionally. If you are not going to only perform the processing for a single column, you should use a recursion flag to prevent the extraneous processing.

    Thanks,

    Chris

     

Reply Children