C#主菜单动态添加子菜单并设置触发事件
我所使用的是devxepress中的主菜单栏时barsubitem控件,想的是在其能够动态添加子菜单栏并能点击触发事件:
/// <summary> /// 创建主按钮的子按钮 /// </summary> public void start_select_items() { for (int i = 0; i < rrl.Count; i++) { BarButtonItem bar = new BarButtonItem(); bar.Caption = rrl[i]; barSubItem1.AddItem(bar); //动态注册事件 bar.ItemClick += new ItemClickEventHandler(DllPlugInItemClick); } } //单击触发子菜单栏 private void DllPlugInItemClick(object sender, ItemClickEventArgs e) { //代码 }