Solved

MenuItem Move

Posted on 2008-06-16
4
361 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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