This question is locked. New answers and comments are not allowed.
I need dynamically add a context menu to radpanelbargroupelement.
the radpanelbargroupelement are created dynamically and I need to have it when you right click the groupelement the menu display and excepts only on the right click for that groupelement. here is what I have but it is not fireing the event when right clicked.
the radpanelbargroupelement are created dynamically and I need to have it when you right click the groupelement the menu display and excepts only on the right click for that groupelement. here is what I have but it is not fireing the event when right clicked.
| private void PopulatePanelBar() |
| { |
| RadPanelBarGroupElement ItemsGroupElement; |
| foreach (BEItems.ItemRow gcr in ItemsDataSet.Item.Rows) |
| { |
| ItemsGroupElement = new RadPanelBarGroupElement(); |
| ItemsRadPanelBar.Items.Add(ItemsGroupElement); |
| ItemsGroupElement.Caption = gcr.Item_nm; |
| ItemsGroupElement.Tag = gcr.Item_id; |
| ItemsGroupElement.MouseDown += new MouseEventHandler(ItemsGroupElement_MouseDown); |
| } |
| foreach (RadPanelBarGroupElement element in this.ItemsRadPanelBar.Items) |
| { |
| RadPanelBarVisualElement visualElement = element.GetCaptionElement(); |
| element.EnableHostControlMode = true; |
| visualElement.AutoToolTip = true; |
| ItemUserControl ItemUserControl = new ItemUserControl(); |
| element.ContentPanel.Controls.Add(ItemUserControl); |
| ItemUserControl.ItemHeaderRow = (BEItems.Item_headerRow[])ItemsDataSet.Item_header.Select("Item_id = " + (int)element.Tag); |
| ItemUserControl.ItemValueRow = (BEItems.Item_valueRow[])ItemsDataSet.Item_value.Select("Item_id = " + (int)element.Tag); |
| } |
| } |
| void ItemsGroupElement_MouseDown(object sender, MouseEventArgs e) |
| { |
| if (e.Button == MouseButtons.Right) |
| { |
| ContextMenu myMenu = new ContextMenu(); |
| if (sender != null) |
| { |
| RadPanelBarGroupElement element = (RadPanelBarGroupElement)sender; |
| element.ContentPanel.ContextMenu = myMenu; |
| MenuItem AddItemRadMenuItem = new MenuItem(); |
| MenuItem UpdateItemRadMenuItem = new MenuItem(); |
| MenuItem InactivateItemRadMenuItem = new MenuItem(); |
| MenuItem ExpandPanelBarRadMenuItem = new MenuItem(); |
| MenuItem CollapsePanelBarRadMenuItem = new MenuItem(); |
| AddItemRadMenuItem.Click += new EventHandler(AddItemRadMenuItem_Click); |
| UpdateItemRadMenuItem.Click += new EventHandler(UpdateRadMenuItem_Click); |
| InactivateItemRadMenuItem.Click += new EventHandler(InactivateItemRadMenuItem_Click); |
| ExpandPanelBarRadMenuItem.Click += new EventHandler(ExpandPanelBarRadMenuItem_Click); |
| CollapsePanelBarRadMenuItem.Click += new EventHandler(CollapsePanelBarRadMenuItem_Click); |
| myMenu.MenuItems.Add(AddItemRadMenuItem); |
| myMenu.MenuItems.Add(UpdateItemRadMenuItem); |
| myMenu.MenuItems.Add(InactivateItemRadMenuItem); |
| myMenu.MenuItems.Add(ExpandPanelBarRadMenuItem); |
| myMenu.MenuItems.Add(CollapsePanelBarRadMenuItem); |
| } |
| } |
| } |