/// <summary> /// 点击按钮后,改变布局,并初始化菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ButtonClick(object sender, EventArgs e) { // 1.比较按钮,设置按钮布局顺序 RadButton clickedButton = (RadButton)sender; int clickedButtonTabIndex = clickedButton.TabIndex; //button 位置 foreach (Control ctl in this.panel1.Controls) { if (ctl is Button) { RadButton btn = (RadButton)ctl; if (btn.TabIndex > clickedButtonTabIndex) { //click button 之后的button if (btn.Dock != DockStyle.Bottom) { btn.Dock = DockStyle.Bottom; btn.BringToFront(); } } else { if (btn.Dock != DockStyle.Top) { btn.Dock = DockStyle.Top; btn.BringToFront(); } } } } //listview加载子菜单 foreach (var item in m_Parent) { if (clickedButton.Tag.ToString() == item.Menu_Id) { this.radListView1.Items.Clear(); List <Base_SysMenu> Childs = GetSysMenuChilds(clickedButton.Tag.ToString()); //获取子菜单 this.radListView1.ImageList = imageList1; this.radListView1.BeginUpdate(); //防止闪烁 foreach (var itemChilds in Childs) { this.radListView1.Items.Add(new ListViewItem { Text = itemChilds.Menu_Name, Tag = itemChilds.Menu_Tags, Name = itemChilds.Menu_Id, ImageIndex = itemChilds.Menu_Img }); } this.radListView1.EndUpdate(); break; } } this.radListView1.BringToFront(); }
public static void ZzAddTestButton(this RadPanel panel, string ButtonText, Point Location, Size Size, Action ButtonClickHandler) { RadButton btn = new RadButton(); btn.Text = ButtonText; panel.Controls.Add(btn); btn.Location = Location; btn.Size = Size; btn.BringToFront(); btn.Click += (s, e) => ButtonClickHandler(); }