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
1834
Header Check Changed and Selective Saving
posted

I am trying to save grid data when the user checks the header checkbox (thus selecting or deselecting everything in the column), but not when the header checkbox changes state due to a user selecting a *cell* checkbox (e.g., when a checkbox in a cell is the first cell in the column to be checked, the header checkbox moves to an intermediate state).

So in the AfterHeaderCheckStateChanged event, I need to tell if it was because the user clicked the header checkbox, or if it was because the user changed a cell checkstate and that caused the header event to fire.  I think I can pull it off with some flags set in CellChange and BeforeHeaderCheckStateChanged, but that approach feels rather kludgey.  Does anyone know of a more elegant solution?

Thanks,

J

Parents
  • 6158
    Verified Answer
    Offline posted

    Hello,

    Unfortunately, there is no built-in functionality in the control to help you determine what triggered the CheckState changed events. Therefore, you'll have to use the existing event structure and set a flag which you can check and reset in the AfterHeaderCheckStateChanged event.

     

    My recommendation would be to use the MouseClick event on the grid, and check to see if the element under the clicked location is a HeaderCheckBoxUIElement.

     

            private bool checkBoxClicked = false;

            private void ultraGrid1_MouseClick(object sender, MouseEventArgs e)

            {

                UIElement clickedElement = ((UltraGrid)sender).DisplayLayout.UIElement.ElementFromPoint(e.Location);

                if (clickedElement != null &&

                    clickedElement.GetAncestor(typeof(HeaderCheckBoxUIElement)) != null)

                    this.checkBoxClicked = true;

            }

     

    If you require further assistance requiring this functionality, feel free to let me know.

    Thank you.

    Chris

     

Reply Children
No Data