开发者

ContextMenu - problem with events

I am working on .NET 2.0 application which uses ContextMenu component. In this menu I have (among others) one item, which contains collection of some other items which I fill programmatically with Popup event handler. Problem is, that this working well only on whole ContextMenu. When I use this:

this.ContextMenu.Popup += new E开发者_C百科ventHandler(onPopup);

Then filling is working fine. But when I want to fill only when submenu pops up, then nothing happened (event is not handled). I use this code:

foreach(MenuItem it in this.ContextMenu.MenuItems)

{
  if(it.IsParent)
  {
    it.Popup += new EventHandler(onPopup);
  }
}

Am I doing something wrong?


I think the solution could be here is to fill all menuitems during initialization of subitem and when popups fires HIDE those ones you don't want to show to user base on current context.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜