Solved

MenuItem Move

Posted on 2008-06-16
4
363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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 …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

627 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