I'm trying to implement a mouse controller for my grid so I can change the cursor under various circumstances, but I'm having a little trouble. The grid has code in several of the mouse events, and when the mouse controller takes over, the grid's mouse events do not fire.
Now, I think it would be relatively simple to fix the problem if I declared the MouseController object in my form WithEvents, then raised events in the mouse controller so that my form could handle them as if the grid itself fired them, but the IMouseController interface does not provide enough methods for that (for example, there is no DoubleClick method).
Are there any sort of "best practices" for overcoming this problem? It all seems so complicated just to simply change a cursor.
ADAdministrator Syncfusion Team May 11, 2004 06:22 AM
You can also control the cursor by overriding OnSetCursor. Here is a KB that discusses this technique as well as the mousecontroller technique.
If you want the grid''s other mouse controllers to control the mouse for some point, you can return 0 in your HitTest. But this would also allow them to control the cursor. So, if you just want to control the cursor, then maybe using an OnSetCursor override is the way to go.
DODonMay 11, 2004 06:25 AM
I tried implementing this with the events that the MouseController could handle and I discovered that there are more problems. For one, when I click on a cell and the MouseController takes over, the current cell that was clicked on does not update. Would the MouseController have to do all this stuff (current cell, selections, etc.) manually? If so, yikes...
DODonMay 11, 2004 06:26 AM
I'll check out that OnSetCursor thing. Thanks.
DODonMay 11, 2004 06:45 AM
I don't know if the OnSetCursor solution is much better. I have to derive the grid and, therefore, can't work with it graphically at design-time. Ugh.
ADAdministrator Syncfusion Team May 11, 2004 09:33 AM
You can add a derived control to your toolbox if you put it in a class library.