Solved

MenuItem Move

Posted on 2008-06-16
4
358 Views
Last Modified: 2012-08-13
I have created a menu in VB.Net and I want when I click the MenuItem, the MenuItem should move up to the top of the list.
0
Comment
Question by:tetoo
4 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 21798823
Please clarify two things...

(1) What version of VB.Net?
(2) Are you using MenuItem or ToolStripMenuItem?
0
 

Author Comment

by:tetoo
ID: 21799059
(1) I am using vb.net 2005 version 2
(2) I am using ToolStripMenuItem
0
 
LVL 10

Assisted Solution

by:margajet24
margajet24 earned 200 total points
ID: 21799486
private void ToolStripMenuItem_ClickToMoveOnTop( object sender, EventArgs e )
{
ToolStripMenuItem item = sender as ToolStripMenuItem;
           
ToolStripMenuItemNAME.DropDownItems.RemoveAt(acToolStripMenuItem.DropDownItems.IndexOf(item));

ToolStripMenuItemNAME.DropDownItems.Insert(0, item);

}

try to imitate this in VB.Net

 - use ToolStripMenuItem_ClickToMoveOnTop as the delegate for the eventhandler
 - use in all ToolStripMenuItem subitems
0
 
LVL 14

Accepted Solution

by:
rachitkohli earned 300 total points
ID: 21800297
Following is the code which will do as per your requirement, you need to replace the menu item & dropdown item names with yours.
Just to simplify , am putting up my scenario for the following code
Main menu is FileToolStripMenuItem
Dropdown menus are NewToolStripMenuItem, OpenToolStripMenuItem, SaveToolStripMenuItem

You can add more dropdown menus after the handle keyword as shown in the code.
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click, OpenToolStripMenuItem.Click, SaveToolStripMenuItem.Click

        Dim ts As ToolStripMenuItem

        ts = CType(sender, ToolStripMenuItem)

        FileToolStripMenuItem.DropDownItems.RemoveAt(FileToolStripMenuItem.DropDownItems.IndexOf(ts))

        FileToolStripMenuItem.DropDownItems.Insert(0, ts)
 

    End Sub

Open in new window

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now