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

Dynamic items added to start menu?

2 Answers 84 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 20 Sep 2010, 08:41 PM
I'm trying to populate the right site of the start menu on the rad ribbon bar with recently access documents. I see how I can load items into there, but how do I handle the events for the clicks if they are being added at run time? Here is my code for adding an item:

 

 

Dim Item As New Telerik.WinControls.UI.RadMenuItem

 

Item.Name =

 

"TestItem"

 

Item.Text =

 

"This is a test menu item"

 

RadRibbonBar1.StartMenuRightColumnItems.Add(Item)


So now how do I programaticly handle the click even for that menu item? Usually I add a click handler through the visual studio IDE for items that already exist... Any help would be appreciated!

2 Answers, 1 is accepted

Sort by
0
Bruce Cooley
Top achievements
Rank 1
answered on 21 Sep 2010, 05:19 PM
I believe you can do the following in VB.

In same place as your code to create the item, you should be able to do the following:
Item.Click += new EventHandler(Item_Click);

Then you can write the event handler similar to:
void Item_Click(object sender, EventArgs e)
{
  //Your Code Here
}


If not, in VS, you should be able to type Item.Click += and then hit tab twice and it should generate the event handler for you.  If you already have the event handler setup, you'll only need to replace Item_Click with the name of your event handler.
0
Stefan
Telerik team
answered on 23 Sep 2010, 03:18 PM
Hello guys,

Thank you for writing.

@Matt, please consider the following code snippet in order to subscribe to the click event of this item:
Public Class Form1
    Friend WithEvents item As New Telerik.WinControls.UI.RadMenuItem
    Public Sub New()
        InitializeComponent()
        Item.Name = "TestItem"
        Item.Text = "This is a test menu item"
        RadRibbonBar1.StartMenuRightColumnItems.Add(item)
    End Sub
 
    Private Sub menuItemClick(ByVal sender As Object, ByVal e As EventArgs) Handles item.Click
        //do something
    End Sub
End Class

I hope you find this information helpful. Should you have any additional questions, do not hesitate to contact me.

Greetings,
Stefan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
RibbonBar
Asked by
Matt
Top achievements
Rank 1
Answers by
Bruce Cooley
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or