Hai all
I have a small doubt regarding contextmenu strip.I have added contextmenu strip item to my windows application with two items "expand" and "collapse".I have also added a empty click event for it.
private void expand_Click(object sender, EventArgs e)
{
//Something
}
private void collapse_Click(object sender, EventArgs e)
{
//Something
}
Now what i need is as soon as as i select either expand or collapse.I want the current mouse position where exactly the expand or collapse is selected.
Hope i made myself clear..
Loading
Dushan StankovicPosted Sep 19, 2009, 5:29 AM
Define in ContextMenuStrip Expand and Collapse ToolStripMenuItems and,
//in constructor
this.expand.Click += new EventHandler(item_Click);
this.collapse.Click += new EventHandler(item_Click);
. . . . .
private void item_Click(object sender, EventArgs e)
{
string cords = string.Empty;
switch ((sender as ToolStripMenuItem).Name)
{
case "expand":
cords = "Expanded at ";
break;
case "collapse":
cords = "Collapsed at ";
break;
}
cords += Form.MousePosition.ToString();
MessageBox.Show(cords);
}
Roei BarPosted Sep 17, 2009, 3:19 AM
You can get the mouse position from