Solved

MenuItem Move

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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