This is a migrated thread and some comments may be shown as answers.

RadContextMenu to RadButtonElement on RibbonBar

1 Answer 54 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Kamila
Top achievements
Rank 1
Kamila asked on 05 Jun 2012, 11:20 AM
Helou

How to add RadContextMenu to RadButtonElement on RibbonBar.

Fore some buttons on RibbonBar i have data in db. 
I don't know how many items there are so I can't define the number of RadMenuItems.
I have no problem with read it from db.

You write
"Select the RadContextMenu component and click its Smart-Tag. From the Action Menu click on the Add ContextMenuManager option. This will create a RadContextMenuManager instance and will add a RadContextMenu property to all the controls on our form.     "
Its not true. There no RadContextMenu property  for controls at ribbon bar (or i can't fint it).

For some controls i wpuld like to do context menu like this

  Pos1
     Item1
     Item2
     Item3
 Pos2
    Item1
 Pos3
   Item1
   Item2


Thanks for help
Kamila

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 06 Jun 2012, 11:31 AM
Hello Kamila,

Thank you for this question.

Please note that a RadContextMenu property will appear on all controls, but not at the elements accommodated by these controls. To make thing more clear, in this particular scenario RadRibbonBar is a control, while RadButtonElement is just an element inside it.

In order to be able to show a RadContextMenu at a RadButtonElement, handle the MouseDown event of this element, check of the mouse button if the right one and call the Show method of the RadContextMenu component:

void radButtonElement1_MouseDown(object sender, MouseEventArgs e)
{
    if (e.Button == System.Windows.Forms.MouseButtons.Right)
    {
        this.radContextMenu1.Show(Cursor.Position);
    }
}

I hope this helps.

Kind regards,
Nikolay
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
ContextMenu
Asked by
Kamila
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or