Windows Develop Bookmark and Share   
 index > Windows Forms General > how do i know which portion of a ToolStripSplitButton is enterd?
 

how do i know which portion of a ToolStripSplitButton is enterd?

Hi, all

I have a ToolStripSplitButton and I wanna show different visual effects between the event that themouse enters the button portion and the mouse enters the dropdown arrow portion. I tried to use b.ButtonSelected and b.DropDownButtonSelected to differentiate these two things, but it doesn't work. When the mouse enters any part of the whole split button, these two properties are both true. How do I tell which portion of the button is entered? I thought of override the OnMouseEnter method but don't know how to get the Mouse position in such an event. Could somebody help me out? Thank you!

newcop2008  Thursday, August 28, 2008 5:54 AM
This ought to solve your problem:

private void toolStripSplitButton1_MouseMove(object sender, MouseEventArgs e) {
evalMouse(sender as ToolStripSplitButton, false);
}
private void toolStripSplitButton1_MouseEnter(object sender, EventArgs e) {
evalMouse(sender as ToolStripSplitButton, true);
}
private void evalMouse(ToolStripSplitButton ctl, bool entered) {
Point pos = ctl.Owner.PointToClient(Control.MousePosition);
pos.X -= ctl.Bounds.Left;
pos.Y -= ctl.Bounds.Top;
Console.WriteLine("{0}, {1}", pos, entered);
}

nobugz  Saturday, August 30, 2008 7:16 PM
This ought to solve your problem:

private void toolStripSplitButton1_MouseMove(object sender, MouseEventArgs e) {
evalMouse(sender as ToolStripSplitButton, false);
}
private void toolStripSplitButton1_MouseEnter(object sender, EventArgs e) {
evalMouse(sender as ToolStripSplitButton, true);
}
private void evalMouse(ToolStripSplitButton ctl, bool entered) {
Point pos = ctl.Owner.PointToClient(Control.MousePosition);
pos.X -= ctl.Bounds.Left;
pos.Y -= ctl.Bounds.Top;
Console.WriteLine("{0}, {1}", pos, entered);
}

nobugz  Saturday, August 30, 2008 7:16 PM

You can use google to search for other answers

Custom Search

More Threads

• Custom UserControl not accepting Key events
• Invalidating...
• Hi MDI Children and Parent Question
• GenericPrincipal authentication
• How to get history of 10 recent web page?
• TabControls with Panels in another class
• How to Cancel BackgroundWorker but still get RESULTS
• ClientConfiguration example in CS101SamplesBCL
• Form Refresh
• Create SQL Logins Using C#.net