Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MenuItem Move

Posted on 2008-06-16
4
Medium Priority
?
366 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 86

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 800 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 1200 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Integration Management Part 2
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

926 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