|
-
Jan 12th, 2011, 06:11 PM
#1
Thread Starter
Lively Member
[RESOLVED] Adding menu items
Hi,
I downloaded a nice menu control from this webpage
http://www.codeproject.com/KB/menus/VistaMenu.aspx.
I added the control to my toolbox, and dragged and dropped it onto my form.
The problem is I can't see any way of adding men items.
There is a property named items, but that doesn't seem to add menu items to the menu. There doesn't seem to be any other property that would add the items.
I'm also wondering if there is a way of adding code to add the menu items.
If there is, could someone show me how
Kareem
-
Jan 12th, 2011, 07:05 PM
#2
Re: Adding menu items
Um, did you bother to read the page you linked to?
Next, populate the menu control, adding menu items. There are several overloaded methods you can use to achieve this:
-
Jan 13th, 2011, 04:58 PM
#3
Thread Starter
Lively Member
Re: Adding menu items
Hi.
Yes Jm I did, but I didn't understand it. What does it mean ?
I mean I know how to create a normal menu in VB, but this is entirely different.
Kareem
-
Jan 15th, 2011, 06:15 PM
#4
Re: Adding menu items
No, this is not completely different. It is EXACTLY the same. They provide an example right there on the page you downloaded from.
Code:
vmcMenu.MenuItems.Add(
"Item " + idx,
"Description " + idx,
img
)
Exactly like the MenuStrip in the .NET Framework, this menu has a property that returns a collection containing the child menu items and that collection has an Add property. This is a pattern that is repeated over and over throughout the .NET Framework and any well-written third-party code. If you know how to use a .NET MenuStrip then you know how to use this menu too.
-
Jan 15th, 2011, 07:21 PM
#5
Re: adding items to menu control
Right on the page the author documents the methods
Code:
public VistaMenuItem Add(string sText);
public VistaMenuItem Add(string sText, string sDescription);
public VistaMenuItem Add(string sText, string sDescription, Image img);
public VistaMenuItem Add(string sText, Image img);
public void Add(VistaMenuItem btn);
Code:
for(int idx = 0; idx < 5; idx++)
vmcMenu.MenuItems.Add(
"Item " + idx,
"Description " + idx,
img
);
-
Jan 15th, 2011, 07:33 PM
#6
Re: adding items to menu control
 Originally Posted by kevininstructor
Right on the page the author documents the methods
Code:
public VistaMenuItem Add(string sText);
public VistaMenuItem Add(string sText, string sDescription);
public VistaMenuItem Add(string sText, string sDescription, Image img);
public VistaMenuItem Add(string sText, Image img);
public void Add(VistaMenuItem btn);
Code:
for(int idx = 0; idx < 5; idx++)
vmcMenu.MenuItems.Add(
"Item " + idx,
"Description " + idx,
img
);
Which is exactly what I said the first time this question was posted. Please do not, under any circumstances, post the same question twice. It is against forum "rules". If you don't feel you have the information you need then post to your existing thread asking for more information.
Of course, in this case you already had the information. You just weren't using it.
-
Jan 15th, 2011, 08:26 PM
#7
Thread Starter
Lively Member
Re: Adding menu items
Hi,
I probably don't understand menus as well as I thought I did. I wrote the following code
Imports VistaMenuControl
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim vmcMenu As New VistaMenuControl.VistaMenuControl
Dim Vmcitem As New VistaMenuItem
Dim vmcmenuitems As New VistaMenuItems
Vmcitem..add("button1", "click")
End Sub
End Class
I got an error meassage on the last line of code saying VistaMenuItems is not a member of VistaMenuControl.VistaMenuItem
I then replaced the last line with the following line
vmcmenuitems.Add("button1", "click")
that still didn't work.
Jm in your last reply, in the sample code what exactly is vmc menu. I mean is it a VistaMenuControl or a VistaMenuItem.
-
Jan 16th, 2011, 08:08 AM
#8
Re: Adding menu items
Duplicate threads merged - please post each question (or variation of it) only once.
-
Jan 16th, 2011, 11:01 AM
#9
Re: Adding menu items
 Originally Posted by kareem1000
Hi,
I probably don't understand menus as well as I thought I did. I wrote the following code
Imports VistaMenuControl
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim vmcMenu As New VistaMenuControl.VistaMenuControl
Dim Vmcitem As New VistaMenuItem
Dim vmcmenuitems As New VistaMenuItems
Vmcitem..add("button1", "click")
End Sub
End Class
I got an error meassage on the last line of code saying VistaMenuItems is not a member of VistaMenuControl.VistaMenuItem
I then replaced the last line with the following line
vmcmenuitems.Add("button1", "click")
that still didn't work.
Jm in your last reply, in the sample code what exactly is vmc menu. I mean is it a VistaMenuControl or a VistaMenuItem.
The highlighed line has two dots, should only be dot, actaully missing .Item
I would suggest adding the menu control to the form via the tool window then add items as follows since you can not add items via the property window as per the author of the menu control
Code:
Dim Item As New VistaMenuControl.VistaMenuItem(VistaMenuControl1)
Item.Text = "Add"
Item.Description = "Add new widget"
Item.ItemTag = 1
VistaMenuControl1.Items.Add(Item)
-
Jan 16th, 2011, 06:32 PM
#10
Thread Starter
Lively Member
Re: Adding menu items
Hi,
Just want to clarify a couple of things.
It seems from what you guys are saying that you can't add a submenu to this type of menu. from example the code that kevininstructor gave me in his last reply, i take it you can't create a submenu off add/add a widget.
And secondly I didn't know it was against forum rules to post the same twice.
i didn't know that it was possible to repost the original thread.
Regards,
Kareem
-
Jan 16th, 2011, 08:12 PM
#11
Re: Adding menu items
 Originally Posted by kareem1000
Hi,
It seems from what you guys are saying that you can't add a submenu to this type of menu. from example the code that kevininstructor gave me in his last reply, i take it you can't create a submenu off add/add a widget.
Regards,
Kareem
This type of menu system does not lend itself to sub-menus and would be awkward if it did.
-
Jan 17th, 2011, 05:11 PM
#12
Thread Starter
Lively Member
Re: Adding menu items
Hi,
Yes, I think fully understood this now. Thanks for you help kevin.
Kareem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|