Event MouseLeftButtonDown on GridViewHeaderCell

2 posts, 0 answers
  1. Sebastien
    Sebastien avatar
    3 posts
    Member since:
    Apr 2014

    Posted 31 Jul 2015 Link to this post


     I tried to implement the MouseLeftButtonDown event and the CellDoubleClick event on a style:

    <Style TargetType="{x:Type telerik:GridViewHeaderCell}">
                <Setter Property="Foreground" Value="White"/>
                <EventSetter Event="CellDoubleClick" Handler="SelectDeselectColumn"/>
                <EventSetter Event="MouseLeftButtonDown " Handler="SelectDeselectColumn2"/>


    The "CellDoubleClick" event works fine but the "MouseLeftButtonDown" event doesn't work! I tried each event alone in the style and the MouseLeftButtonDown never works!

    In the class "GridViewHeaderCell" there is no event accessible for MouseLeftButtonDown, there is only a method called "OnMouseLeftButtonDown" My guess is that the event MouseLeftButtonDown (or MouseDown) is already handled somewhere else...

    If I want to use the method "OnMouseLeftButtonDown" I have to create a new ​child class that the parent is "GridViewHeaderCell". But I don't know where to allocate the new class in the code. Is there a event like "AutogeneratingCoumn"?

    Is there any other options possible to support the MouseLeftButtonDown event or a single click?







  2. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 03 Aug 2015 Link to this post


    The reason for this is that the event is internally handled by RadGridView.
    You can try subscribing for the click event of the GridViewHeaderCell (with HandledEventsToo) and get the information you need from the clicked HeaderCell.
    For example:
    this.AddHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnMouseLeftButtonDown), true);
    private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        var result = (e.OriginalSource as FrameworkElement).ParentOfType<GridViewHeaderCell>();
        if (result != null)
            // the user have clicked on a header cell
             var column = result.Column;

    I hope this helps. 

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top