Q3 Row.MouseLeftButtonDown not working

6 posts, 0 answers
  1. Przemyslaw
    Przemyslaw avatar
    21 posts
    Member since:
    Oct 2007

    Posted 05 Nov 2009 Link to this post

    Hi

    I attach events to my GridView rows. The MouseWheel event works and the MessageBox shows up when I rotate the mouse wheel. However, the MouseLeftButtonDown event does NOT work. This seemed to work before I upgraded the project from Q2. Could you please let me know if I am doing something wrong or if there is a bug in this release.

            //Constructor
            public Player_GridView(int userid)
            {
               [...]
                RowLoaded += SetDescriptions;
            }

            private void SetDescriptions(object sender, RowLoadedEventArgs e)
            {
                e.Row.MouseLeftButtonDown += Row_Clicked;
                e.Row.MouseWheel += Row_MouseWheel;
            }

            private void Row_Clicked(object sender, MouseButtonEventArgs e)
            {
                MessageBox.Show("Mouse down");
            }

            void Row_MouseWheel(object sender, MouseWheelEventArgs e)
            {
                MessageBox.Show("MouseWheel");
            }

    Przemek
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 05 Nov 2009 Link to this post

    Hi Przemyslaw,

    The latest version of RadGridView handles the MouseLeftButtonDown and MouseLeftButtonUp events and as a result the your existing code is not able to handle those events.

    You can workaround this problem by subscribing to MouseDown eventin code which gives the option to handle already handled events. For example:

    public Window1()
    {
        this.InitializeComponent();
         
        this.gridView.AddHandler(GridViewCell.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnGridMouseLeftButtonDown), true);
    }
      
    private void OnGridMouseLeftButtonDown(object s, MouseButtonEventArgs args)
    {
        var senderElement = (FrameworkElement)args.OriginalSource;
        var clickedRow = senderElement.ParentOfType<GridViewRow>();
      
        if (clickedRow != null)
        {
            // execute logic
        }
    }

    Hope this helps.


    All the best,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Przemyslaw
    Przemyslaw avatar
    21 posts
    Member since:
    Oct 2007

    Posted 05 Nov 2009 Link to this post

    Hi Milan

    thank you for your response. I will refactor my code tomorrow. I have a further question or clarification. You have written that the MouseLeftButtonDown (Up) events are handled by the RadGridView control and therefore the user code is not able to handle these events itself. However, my further investigation and trials showed that when I click on the very verge of a row (almost on the line separating two rows) then the MouseLeftButtonDown event handler in MY code IS actually executed. Is that a correct behavior?

    Przemek
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 06 Nov 2009 Link to this post

    Hi Przemyslaw,

    Well, actually it is the cells that handle most of the mouse event but the row separating lines are actually part of the rows themselves which do not handle mouse events (like Up, Down). In short, for the time being the behavior that you have described is expected.

    Hope the information is helpful.

    All the best,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Marcus Lambert
    Marcus Lambert avatar
    41 posts
    Member since:
    Aug 2009

    Posted 30 Nov 2009 Link to this post

    Hi,
    I am suffering from this problem as well and it it not clear what the options are now.
    I take it that we cannot use MouseLeftButtonDown & MouseLeftButtonUp

    Please could someone list in post what the current opttion for mouse clicks on the grid are. The current sticky needs more detail.
    I was wireing up a command in prism in the xaml to my ViewModel. now it looks like I cant do that now as every solution is code behind.

    Marcus
  7. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 03 Dec 2009 Link to this post

    Hi Marcus Lambert,

    Could you please check the response to your last question on this thread


    All the best,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
DevCraft banner