I have a custom CustomToolStripMenuItem which is derived from ToolStripMenuItem Class. In that custom class 'CustomToolStripMenuItem', I override OnPaint(), OnMouseMove() and OnMouseDown() Events.
Here, I want to add a rectangle to show on each sub menu to delete that menu item from customized tool strip menu items. When user move mouse to rectangle area, it will change back color which shows that user want to delete that item. I add these menus by reading an xml file.
The main problem here is that, when I move the mouse from one menu item to other quickly, previous item also shown as selected. How can I ensure that when mouse move to other menu item, previous selection should erase.
What I guess, I need to repeat that mouse move event for specific times (total items in xml file), but How can I do this with events of mouse ???
Any Help ?
You can also use MouseLeave event with current events, if fast mouse move bypasses your current MouseMove event!
Related
I have a UWP app in which I have several buttons. Once the app starts to run, I set the focus in my code to the first button using a code like this:
firstButton.Focus(FocusState.Programmatic);
After this point, what I am interested in is that once the user use the mouse wheel, the UWP app automatically scroll to second, third, fourth, ... button(exactly like when we use tab key on keyboard to move between buttons).
However, when I use mouse wheel, nothing happens in the app.
I should also say that in firstbutton xaml, I use pointerwheelchanged event listener to change the focus to second button. However, this event handler does not work with mouse wheel UNTIL I MOVE THE MOUSE CURSOR INSIDE THE AREA OF FIRST BUTTON. What I am interested in is that this scrolling using mouse wheel becomes automatic exactly like the tab key of keyboard.
Any suggestions?
Place the event on the container control (like the Grid). If it's a control that already processes the event, use the AddHandler method with handledEventsToo set to true.
I want to make mouse pointer disable on some folders based on certain condition while doing Drag drop operation.Please tell me how to do this in WPF as I am unable to show the restrict icon of that mouse pointer while hovering the dropped element.
Inside the MouseEnter Event Handler Put this code based on your condition:
Mouse.OverrideCursor = Cursors.No;
I am trying to implement drag and drop behaviour within a WPF Treeview. As part of this I need to expand the currently hovered over node if the mouse has been over the node for a set period of time once the DragOver event has been triggered.
I have been able to successful delay the expansion using a DelayedAction on the node that triggered, but I have been unable to successful check the current position of the mouse once the delayed action has triggered. Currently, even if the mouse has moved off the node and the click released, after the delay, the node will still expand.
I need to be able to check the current position of the mouse after the delay, and only expand the node if the mouse is still over the node.
I was able to solve this with an answer from a different question here. The thread I used is available here:
How do I get the current mouse screen coordinates in WPF?
I used the Win32 approach to get the correct mouse position after the delay and use this to get the current TreeViewItem under the mouse by using a hit test.
If the current TreeViewItem is the same as the TreeViewItem that triggered the DragOver event then I expand the node, or else do nothing.
I have a grid-view with merged cells and rows which look like this.
I am using grid view mouse enter cell and mouse leave cell events to call the tool-tip show and hide methods.
Problem I am having is, since the cells are very closer tooltip get displayed when I moving across the grid. What I am trying to achieve is display the tooltip only when mouse is stop moving.
Is it possible to capture current state of mouse where I can capture mouse is moving or not.
I have looked at the Control.MouseMove Event, but can I find the current state of the mouse using that.
Update
I did try something like this
In MouseMove event of the gridview tooltip.Hide()
In
MouseHoverCell tooltip.Show() but had no luck with it
Thanks
What you need here is to leverage the OnMouseHover and OnMouseMove events.
The OnMouseHover event is fired when the mouse stops moving. So, in your case, you can fire this event when the mouse stops, pick up the containing cell and show your tooltip. When the OnMouseMove event fires teardown the tooltip and start again.
I hope this helps.
In Excel, middle mouse button click work as a toggle. That is, if you press it once, it will allow you to scroll in your chosen direction till the time you click it again.
However, in Infragistics Ultragrid, this scrolling functionality is available only while middle mouse button remains pressed. How can I make Infragistics Ultragrid middle mouse button click work as in excel?
Otherwise also, what is the way to do it in winforms?
It's not as complicated as you might think. Clicking either the mouse wheel or middle button (depending on the type of Mouse the user has) fires off a MouseWheel event which must be handled and processed like any other event.
You'll need to configure a small "scrolling state machine" for you application. By this, I mean that the user is either scrolling in, say, a NormalMode, where using scroll bars or flicking up/down on the mouse wheel produces the same effect (scrolling up/down). Or, the application is in a HoverScrollingMode which occurs whenever the user has clicked the middle button (or mouse wheel) and is moving the mouse north or south of the click point.
I can't give you a programming example without seeing how your application currently handles other types of mouse events, but your overall strategy is to handle these MouseWheel events, use them to switch your application state (into, say, HoverScrollingMode) and then programmatically move the viewport up/down depending on the current position of their mouse.
Hope this helps, and good luck!