Windows Develop Bookmark and Share   
 index > Windows Forms Designer > how to chnage cusor for Dynamic created Context menu
 

how to chnage cusor for Dynamic created Context menu

i had created a context menu at run time intializing with form iam using .net framework 2.0 and langugae C#

public ScriptForm()

{

// ObjDeleagte = new Delegate();

InitializeScriptColors();

PopulateContextMenu();

}

void PopulateContextMenu()

private

{

ObjContextMenu =new ContextMenu();

ObjContextMenu.MenuItems.Add(new MenuItem("cut"))

ObjContextMenu.MenuItems[0].Click +=; new EventHandler(Cut_Click);


ObjContextMenu.MenuItems.Add(new MenuItem("copy")); new

ObjContextMenu.MenuItems[1].Click +=new EventHandler(Copy_Click);

ObjContextMenu.MenuItems.Add(new MenuItem("Paste"));

ObjContextMenu.MenuItems[2].Click +=new EventHandler(Paste_Click);

ObjContextMenu.MenuItems.Add( new MenuItem("Delete"));

ObjContextMenu.MenuItems[3].Click +=EventHandler(Delete_Click);

}

this form also contain a text box "ScriptRichText"


on which i had put mouse event in which in showing my objContextmenu

but the problem is that it is showing edit mode cursor over context menu same as text box
but i want to have "arrow" type cursor


code for mouse click
private void ScriptRichText_MouseClick(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Right)

{

ObjContextMenu.Show(this.ScriptRichText, new Point(e.X, e.Y));

}

}
what should i do ?????

rekhil  Thursday, April 16, 2009 10:02 AM

Hi Rekhil,

I performed a test on this issue but didn't reproduce the problem on my side. When the ContextMenu shows and I move pointer to it, the cursor becomes arrow shape.The following is the code in my test.

public partial class Form1 : Form
{
ContextMenu cm = new ContextMenu();

public Form1()
{
InitializeComponent();
cm.MenuItems.Add(new MenuItem("aa"));
this.textBox1.MouseUp += new MouseEventHandler(textBox1_MouseUp);
}

void textBox1_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.cm.Show(this.textBox1,e.Location);
}
}
}

Please try the above code on your side to see if the cursor becomes arrow shape when you move the pointer to the ContextMenu.

Sincerely,
Linda Liu

Linda Liu  Monday, April 20, 2009 8:31 AM
We are changing the issue type to “General Discussion�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Linda Liu  Wednesday, April 22, 2009 4:06 AM

You can use google to search for other answers

Custom Search

More Threads

• What is wrong with MyDataset is nothing?
• I need the list control (styled with check boxes) to move its focus and selects the list item that I just checked.
• DataGridView Custom Cell - Every Cell
• Tutorial on creating controls
• Copy Form Design to another Form or Application?
• how to create a textbox by clicking a button
• default values for inherited control
• ComboBox in a DesignerActionItemCollection
• Can I use a wizard without a form?
• How to register an activex control