Context menu in Combo Control

  • Thread starter Thread starter Abhi
  • Start date Start date
A

Abhi

I've created a class "MRP123MenuItem" derived from
inbuilt MenuItem class to give customized look and feel to
the user. I've created context menus for different
controls using mine MRP123MenuItem's and it all works fine
except for ComboBox control. It only displays a strip of
context menus without any content. I'm unable to
understand why it is happening though it works fine when
used along with any other control.
Please help me out.
 
-
I've created a class "MRP123MenuItem" derived from
inbuilt MenuItem class to give customized look and feel to
the user. I've created context menus for different
controls using mine MRP123MenuItem's and it all works fine
except for ComboBox control. It only displays a strip of
context menus without any content. I'm unable to
understand why it is happening though it works fine when
used along with any other control.
Please help me out.


Not sure if i understand your problem correctly. Here is what I tried and
it worked for me in VS 2003. net

I had my own MenuItem class:

public class MyMenuItem : MenuItem
{
public MyMenuItem (string name):base (name)
{
}
}


and then in my combobox control i did the following:

this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(88, 21);
this.comboBox1.TabIndex = 0;
this.comboBox1.Text = "comboBox1";
this.comboBox1.Items.Add ("Hello");
this.comboBox1.Items.Add("Hi");
ContextMenu menu = new ContextMenu ();;
MyMenuItem menuItem1 = new MyMenuItem ("hello");
menu.MenuItems.Add ((MenuItem)menuItem1);
this.comboBox1.ContextMenu = menu;


Right clicking on this combobox returns to me my context menu.

Hope this helps you out.

--
Adrian Mascarenhas, Developer Division

This posting is provided "AS IS" with no warranties, and confers no rights.

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
 
Back
Top