I know this is easy but since I can't find the answer...
Normal everyday grid. Middle Mouse Click will show the scroll up/down cursor and allow the entire grid to scroll up/down. How do I turn this off and tell the grid not to perform any actions on a middle mouse click?
I want to handle that type of click on my own. For example, on a left mouse click of a row, display a nice picture. On a middle mouse click of a row, send an email. Right mouse click, context menu.
Thanks in advance.
Hello,
You probably need to handle the MosueClick event of the UltraGrid. what you could do is something like the following:
void ultraGrid1_MouseClick(object sender, MouseEventArgs e) {
//Checking which button is pressed (Right, Middle, Left) if (e.Button == MouseButtons.Middle) { //Here you should do what you want } }
Please let me know if this is what you are looking for
Correct. I will be using something very much like that code. What I need to turn off in the grid though is the mouse/cursor the grid displays as the operation I perform may be several seconds.
The mouse affordance I am talking about is the round circle with the up/down arrows in the middle.
Hi,
I don't think there is any way to turn this off. In fact, I'm not even sure that the grid has any control over this - it may be controlled by the mouse driver on the machine.
Found a solution. You have to derive from the UltraGrid class and override the OnMouseDown method. Something like the following code will get you there:
public class MyGrid : UltraGrid { protected override void OnMouseDown(MouseEventArgs e) { if (e.Button != MouseButtons.Middle) base.OnMouseDown(e); } }
Obviously you need to bolster the code to help you do something useful but that will prevent the undesirable auto scrolling "feature".
This would be something Very Easy for the grid to offer up as a property:
myUltraGrid.DisplayLayout.Override.MiddleMouseBehavior = blah.blah.blah.
The solution proposed above is going to prevent the mousedown event from firing. In general, you should always call the base method of any of the framework's OnSomeEventName methods because these methods are responsible for raising the corresponding event.
This is also a bump on this thread to see if anyone has come up with a real solution.