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
75
how can i write a "header single click" event in ultragrid
posted

how can i write a "header single click" event in ultragrid or can i use cell click for checking the grid header click

or any other event that is present in the list or can i use mouse click but how to identify a header in the mouse click event or cell click ..! ?

help

ram

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi Ram,

    There's no specific event for clicking on a column header, but you can achieve this using the UIElements.I have attached a small sample project here which demonstrates how it's done.

    Here's the relevant code:


            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                UltraGridLayout layout = e.Layout;
                UltraGridOverride ov = layout.Override;

                // This basically tells the grid to do nothing when a header is clicked.
                ov.HeaderClickAction = HeaderClickAction.Select;
                ov.SelectTypeCol = SelectType.None;
            }

            private void ultraGrid1_MouseUp(object sender, MouseEventArgs e)
            {
                UltraGrid grid = (UltraGrid)sender;
                UIElement element = grid.DisplayLayout.UIElement.LastElementEntered;

                // First, check if the element itself is a HeaderUIElement.
                HeaderUIElement headerUIElement = element as HeaderUIElement;

                // If not, see if it has an ancestor that it a HeaderUIElement
                if (null == headerUIElement)
                    headerUIElement = element.GetAncestor(typeof(HeaderUIElement)) as HeaderUIElement;

                // If we didn't find a HeaderUIElemnt by now, then the mouse is not in a Header.
                if (null == headerUIElement)
                    return;

                // Now get the column.
                UltraGridColumn column = headerUIElement.Header.Column;
                if (null == column)
                {
                    // The column will be null if the HeaderUIElement is a Band or Group Header.
                    return;
                }

                MessageBox.Show(this, "Header clicked:  " + column.Key);                
            }

    WinGrid - Column Header Click - CS.zip
Reply Children
No Data