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 renameSwatchMen uItem is either undeclared or was never assigned.
The variable deleteSwatchMen uItem 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.ContextMe nu meContextMenu;
protected MenuItem renameSwatchMen uItem;
protected MenuItem deleteSwatchMen uItem;
protected bool meContextMenuEn abled = true;
....
protected SwatchPanel()
{
InitializeCompo nent();
this.meContextM enuEnabled = true;
EnableContextMe nu(false);
}
private void InitializeCompo nent()
{
this.components = new System.Componen tModel.Containe r();
this.meColorTip = new System.Windows. Forms.ToolTip(t his.components) ;
this.deleteSwat chMenuItem = new System.Windows. Forms.MenuItem( "Delete Swatch", new EventHandler(th is.m_contextMen u_Popup));
this.renameSwat chMenuItem = new System.Windows. Forms.MenuItem( "Rename Swatch", new EventHandler(th is.m_contextMen u_Popup));
this.SuspendLay out();
this.meColorTip .Active = false;
this.meContextM enu = new ContextMenu(new System.Windows. Forms.MenuItem[] { this.deleteSwat chMenuItem,
this.renameSwat chMenuItem});
this.meContextM enu.Popup += new System.EventHan dler(this.m_con textMenu_Popup) ;
this.ContextMen u = this.meContextM enu;
this.ResumeLayo ut(false);
}
private void m_contextMenu_P opup(object sender, System.EventArg s e)
{
MenuItem miClicked = null;
if (sender is MenuItem)
miClicked = (MenuItem)sende r;
else
return;
string item = miClicked.Text;
switch (item)
{
case "Delete Swatch" : DeleteSwatch(th is.meRightClick Point);
break;
case "Rename Swatch" : RenameSwatch(th is.meRightClick Point);
break;
}
}
internal void EnableContextMe nu(bool enable)
{
if (enable)
{
if (!this.meContex tMenuEnabled)
{
this.meContextM enu.Popup += new System.EventHan dler(this.m_con textMenu_Popup) ;
this.meContextM enuEnabled = true;
}
}
else
{
if (this.meContext MenuEnabled)
{
this.meContextM enu.Popup -= new System.EventHan dler(this.m_con textMenu_Popup) ;
this.meContextM enuEnabled = false;
}
}
}
Comment