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
225
execute some code when user click on column header
posted

I need to execute some code when the user click on the column heander instead to sort them, It´s that posible?

 

Thanks in advace,

Alejandro Castrejon

Parents
  • 69832
    Verified Answer
    Offline posted

    One way is to set SortIndicator to 'None' for the column, then handle the AfterSelectChange event for column selection. This event will also fire, however, when a column is programmatically selected, so if you need to unambiguously identify a click on the header, you can do this:

    void ultraGrid_MouseClick(object sender, MouseEventArgs e)
    {
        UltraGrid control = sender as UltraGrid;
        UIElement controlElement = control.DisplayLayout.UIElement;
        UIElement elementAtPoint = controlElement != null ? controlElement.ElementFromPoint( e.Location ) : null;
        UltraGridColumn column = null;

        while ( elementAtPoint != null )
        {
            HeaderUIElement headerElement = elementAtPoint as HeaderUIElement;
            column = headerElement != null ? headerElement.GetContext( typeof(UltraGridColumn) ) as UltraGridColumn : null;
            if ( column != null )
                break;

            elementAtPoint = elementAtPoint.Parent;
        }

        if ( column != null )
        {
            //  Do stuff here
        }

    }

Reply Children
No Data