Skip to content

Infragistics Community Forum / Cross Platform / Ultimate UI for Xamarin / How do I change the mouse cursor upon mouseover a cell?

How do I change the mouse cursor upon mouseover a cell?

New Discussion
Andrew
Andrew asked on Jan 23, 2014 5:03 AM

In the XamGrid, what is the best way to change the mouse cursor (to a hand) upon mouse-over cells in a particular column?

Sign In to post a reply

Replies

  • 0
    [Infragistics] Elena
    [Infragistics] Elena answered on Nov 14, 2011 9:09 AM

    Hello Andy99,

     

    I was looking into your question and I believe that depending on your specific scenario, different approaches may be more suitable for changing the mouse cursor. If the specific column you are referring is from type TemplatedColumn you can just set the Cursor property of the controls you use in the template. If this is not your case, I can suggest you handle the MouseEnder event for the CellControl and use the following code snippet:

            void Control_MouseEnter(object sender, MouseEventArgs e)

            {

                if ((sender as CellControl).Column.Key == "Name")

                    this.Cursor = Cursors.Hand;

                else

                    this.Cursor = Cursors.Arrow;

            }

    If you have any further questions on the matter, please do not hesitate to ask.

    • 0
      Andrew
      Andrew answered on Nov 16, 2011 3:02 PM

      Elena,

       

      Thanks for your reply. Could you please clarify in which grid event I can use to assign this event handler to the cellcontrol?

      • 0
        [Infragistics] Elena
        [Infragistics] Elena answered on Nov 17, 2011 8:37 AM

        Hello Andy99,

         

        XamDataGrid exposes event named CellControlAttached, which you can use to set a different properties for a cell when it is loaded. This is why I believe that it is suitable to add the handler of the MouseMove event there.

         

                private void xamGrid1_CellControlAttached(object sender, CellControlAttachedEventArgs e)

                {

                    e.Cell.Control.MouseEnter += new MouseEventHandler(Control_MouseEnter);

                }

         

        Please let me know if this doesn’t suit your scenario.

      • 0
        Andrew
        Andrew answered on Nov 17, 2011 2:18 PM

        Elena,

        No, this does not work – please see the attached example and advise.

      • 0
        [Infragistics] Elena
        [Infragistics] Elena answered on Nov 17, 2011 2:54 PM

        Hello Andy99,

         

        For some reason I get an error message when I try to run the sample. However I have a look at your code and I notice that you have set the cursor for the CellControl. After some investigation I noticed that the XamGrid handles differently this scenario and for the CellControl, so I can suggest you set the cursor directly on the Cursor property of the window:

         

        this.Cursor = Cursors.Hand;

         

        Please let me know if this still doesn’t suit your scenario.

      • 0
        Andrew
        Andrew answered on Nov 17, 2011 4:41 PM

        Thanks Elena, this works now.

        Please note that I also had to implement a MouseLeave event to make sure that the pointer would get reset when leaving the cell.

        The reason my example solution had errors is because I changed the references to the Infragistics Components as I did not want to include those dlls. If you wanted to get it to work I would suggest you remove the references to the 3 Infragistics dlls and re-add them.

    • 0
      Ankita Patel
      Ankita Patel answered on Jan 23, 2014 5:03 AM

      hey thans in advance, my question is that how can i set this method to  the perticuler column where i have used multicolumn listview so column name which is ID is in other xml and i want to change the curser in the column which is in the listview so please help me

      you can mail me on ankita.patel@acmatix.com ..pleaze help!

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Andrew
Favorites
0
Replies
7
Created On
Jan 23, 2014
Last Post
12 years, 8 months ago

Suggested Discussions

Created by

Created on

Jan 23, 2014 5:03 AM

Last activity on

Feb 19, 2026 9:01 PM