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

VB.net Create Menu From Database

4 Answers 213 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Dadan
Top achievements
Rank 1
Dadan asked on 22 Nov 2012, 08:39 AM
I'm trying to create dynamic Ribbon Bar menu at runtime. 
All properties for every item in the menu is stored in database (idmenu, caption, image (i store only the image index, not the image object), etc). I also need to create event handler which fired when the menu is selected.
I'm trying to use all available ribbon items in my Ribbon Bar menu (Button element, tab, gruop button , dropdown button, etc).
For the button element, i want to use small image (16x16) for some elements, but i want to use large image (32x32) for some other elements.

Anyone has any idea how to do this in vb.net with telerik winforms component ??
thx for your attention.

4 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 23 Nov 2012, 03:52 PM
Hello Dadan,

If I understand correctly, by 'menu is selected' you mean when a tab from RadRibbonBar is selected as the other elements in RadRibbonBar do not support selected. If so, the event is CommandTabSelected:

AddHandler RadRibbonBar1.CommandTabSelected, AddressOf RadRibbonBar1_CommandTabSelected
 
Private Sub RadRibbonBar1_CommandTabSelected(sender As Object, args As Telerik.WinControls.UI.CommandTabEventArgs)
 
End Sub
You can read more information about creating elements in RadRibbonBar in this article and the other articles in the same section. Using the information that you will find there, you can loop over your data object (i.e. DataTable) and create the respective elements. You will also need to store some kind of parent id, which determines where an element should be placed.

As to the images, you can have two different ImageLists - one for 16x16 and one for 32x32. A column in your database will tell from which ImageList the image will be pulled out and another column will contain the index by which you should get the image from the specified ImageList.

I hope this helps.

All the best,
Nikolay
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Dadan
Top achievements
Rank 1
answered on 28 Nov 2012, 06:49 AM
Thx very much Nikolay,
I Try your suggestion and now i've made my menu aplication based on database.

Now, i'm confusing on how to find specified node in treeview.
I use method radtreenode.find("node.text") and it show the first node with the same text.
but, mynode.text is not unique. i have some nodes with same text, but with different parent.
i've set the mynode.name as a unique value.

how can i find a node with parameter mynode.name ?
after finding the specified node, i want that node to be visible ( expanded with all it's parent ).

once again, thx for your fast response, sorry if my english is bad,
0
Dadan
Top achievements
Rank 1
answered on 29 Nov 2012, 03:15 AM
Updated :

i've find a way to find the specified node from the telerik documentation.
but, i'm still confusing how to get all node in treeview. because radtreeview.nodes only give the root node.

i set allowdragdrop property = true.
after drag & drop process, i want to know, one node before the selected node and one node after the selected node
I try use Radtreeview.selectednode.prevnode, but it return the previous node before i move the selected node.

can anyone tell me how to do that ?
0
Accepted
Nikolay
Telerik team
answered on 30 Nov 2012, 05:01 PM
Hi Dadan,

The nodes of RadTreeView are kept in a hierarchy. I.e. RadTreeView has a Nodes collection that contains the nodes at the root level and each of these nodes has a Nodes property that its child nodes. So, in order to get all Nodes of RadTreeView you should use recursion looping through the Nodes collections of all nodes.

As to the previous and next nodes of the dragged and dropped node, you should handle the DragEnded event and take the PrevNode and NextNode of the Node that comes from the event argument:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
 
        this.radTreeView1.DragEnded += new Telerik.WinControls.UI.RadTreeView.DragEndedHandler(radTreeView1_DragEnded);
    }
 
    void radTreeView1_DragEnded(object sender, Telerik.WinControls.UI.RadTreeViewDragEventArgs e)
    {
        Console.WriteLine("PrevNode " + e.Node.PrevNode.Text + " NextNode " + e.Node.NextNode.Text);
    }
}

A bit of topic, I would kindly ask you to open a new thread for each question that is not related to the main topic of the existing threads. This will avoid mixing several different topics (like in the current case - for RadRibbonBar and RadTreeView) in one thread, hence our community will be able to find information for the topics more easily in case it is interested.

Greetings,
Nikolay
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
RibbonBar
Asked by
Dadan
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Dadan
Top achievements
Rank 1
Share this question
or