VS 2008 and context menus
- From: steve <s_j_bull@xxxxxxxxx>
- Date: Mon, 30 Jun 2008 18:33:04 -0400
I have a class which includes a context menu. The class, and context menu, appears to work fine when I run the application but when
I look at the designer for the class I get the errors :
The variable renameSwatchMenuItem is either undeclared or was never assigned.
The variable deleteSwatchMenuItem is either undeclared or was never assigned.
Any ideas of how I can track the problem down would be welcome. The following is the relevant code
Thanks,
Steve
....
protected System.Windows.Forms.ContextMenu meContextMenu;
protected MenuItem renameSwatchMenuItem;
protected MenuItem deleteSwatchMenuItem;
protected bool meContextMenuEnabled = true;
....
protected SwatchPanel()
{
InitializeComponent();
this.meContextMenuEnabled = true;
EnableContextMenu(false);
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.meColorTip = new System.Windows.Forms.ToolTip(this.components);
this.deleteSwatchMenuItem = new System.Windows.Forms.MenuItem("Delete Swatch", new EventHandler(this.m_contextMenu_Popup));
this.renameSwatchMenuItem = new System.Windows.Forms.MenuItem("Rename Swatch", new EventHandler(this.m_contextMenu_Popup));
this.SuspendLayout();
this.meColorTip.Active = false;
this.meContextMenu = new ContextMenu(new System.Windows.Forms.MenuItem[] { this.deleteSwatchMenuItem,
this.renameSwatchMenuItem});
this.meContextMenu.Popup += new System.EventHandler(this.m_contextMenu_Popup);
this.ContextMenu = this.meContextMenu;
this.ResumeLayout(false);
}
private void m_contextMenu_Popup(object sender, System.EventArgs e)
{
MenuItem miClicked = null;
if (sender is MenuItem)
miClicked = (MenuItem)sender;
else
return;
string item = miClicked.Text;
switch (item)
{
case "Delete Swatch" : DeleteSwatch(this.meRightClickPoint);
break;
case "Rename Swatch" : RenameSwatch(this.meRightClickPoint);
break;
}
}
internal void EnableContextMenu(bool enable)
{
if (enable)
{
if (!this.meContextMenuEnabled)
{
this.meContextMenu.Popup += new System.EventHandler(this.m_contextMenu_Popup);
this.meContextMenuEnabled = true;
}
}
else
{
if (this.meContextMenuEnabled)
{
this.meContextMenu.Popup -= new System.EventHandler(this.m_contextMenu_Popup);
this.meContextMenuEnabled = false;
}
}
}
.
- Follow-Ups:
- Re: VS 2008 and context menus
- From: steve
- Re: VS 2008 and context menus
- Prev by Date: Re: How to use CompareString() method
- Next by Date: Re: How to use CompareString() method
- Previous by thread: Re: LINQ book
- Next by thread: Re: VS 2008 and context menus
- Index(es):
Relevant Pages
|