473,597 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extending the Menu strip in .NET 2.0 to display text on a status strip label

I thought this was useful, its a extender i just wrote for the new .NET menu
strip and status strip to extend the menu items to add a status message so
when a mouse rolls over the item it displays the text on the status strip
lable specified for the extender.. all you have to do is copy this to a code
file, and add it as a control to your form. set the status lable property of
the extender control then set the status mesages of the menu items and run
it and watch it do its thing
Imports System

Imports System.Collecti ons

Imports System.Componen tModel

Imports System.Windows. Forms

<ProvidePropert y("StatusMessag e", GetType(Compone nt))> _

Public Class StatusMessage

Inherits Component

Implements IExtenderProvid er

Dim ht_ControlLooku p As Hashtable = New Hashtable

Dim s_LastMessage As String = String.Empty

Public Sub SetStatusMessag e(ByVal senderComponent As Component, ByVal
strMessage As String)

If Not ht_ControlLooku p.Contains(send erComponent) Then

ht_ControlLooku p.Add(senderCom ponent, strMessage)

Dim pMenuItem As ToolStripMenuIt em = CType(senderCom ponent,
ToolStripMenuIt em)

If pMenuItem IsNot Nothing Then

AddHandler pMenuItem.Mouse Move, AddressOf Handle_MenuSele ct

AddHandler pMenuItem.Mouse Leave, AddressOf Handle_MenuLeav e

AddHandler pMenuItem.Mouse Enter, AddressOf Handle_MenuEnte r

Else

ht_ControlLooku p(senderCompone nt) = strMessage

End If

End If

End Sub

Public Function GetStatusMessag e(ByVal senderComponent As Component) As
String

If ht_ControlLooku p.Contains(send erComponent) Then

Return ht_ControlLooku p(senderCompone nt).ToString

End If

Return String.Empty

End Function

Public Function CanExtend(ByVal senderComponent As Object) As Boolean
Implements System.Componen tModel.IExtende rProvider.CanEx tend

Return TypeOf senderComponent Is ToolStripMenuIt em

End Function

Private m_StatusBar As ToolStripStatus Label

Public Property StatusBar() As ToolStripStatus Label

Get

Return m_StatusBar

End Get

Set(ByVal value As ToolStripStatus Label)

m_StatusBar = value

End Set

End Property

Private Sub Handle_MenuSele ct(ByVal pControl As Object, ByVal e As
MouseEventArgs)

If StatusBar Is Nothing Then

Exit Sub

End If

If ht_ControlLooku p.Contains(pCon trol) Then

If Not ht_ControlLooku p(pControl).ToS tring.Trim = String.Empty Then

StatusBar.Text = ht_ControlLooku p(pControl).ToS tring

End If

End If

End Sub

Private Sub Handle_MenuLeav e(ByVal pControl As Object, ByVal e As EventArgs)

If StatusBar Is Nothing Then

Exit Sub

End If

StatusBar.Text = Me.s_LastMessag e

End Sub

Private Sub Handle_MenuEnte r(ByVal pControl As Object, ByVal e As EventArgs)

If StatusBar Is Nothing Then

Exit Sub

End If

Me.s_LastMessag e = StatusBar.Text

End Sub
End Class
Nov 23 '05 #1
0 2074

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2930
by: Lea | last post by:
Hi, I have difficulties in understanding the following script. If a good soul was passing by here ... Thks Lea <script language="javascript">
2
3874
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at http://home.pacific.net.sg/~jacksony ? (the drop down bar could not work at www.apchosting.net but can drop at home.pacific.net.sg. I suspect it is a server problem but was told it is not possible, therefore assuming it is a client script problem? the script works last time...
4
5183
by: Stromboli | last post by:
hi people, My problem is that I need to build a dynamic menu (preferably that works in all the browsers) that appears when I mouseover a certain link. The problem is that I have to declare the menu content in the same part of the page where the menu goes (BODY). The content of the page is generated dynamically so I can't put the menu content it on the headers.
0
2165
by: Tree menu using XML | last post by:
I have one XML file that has nodes and sub node and each and every node has the attribute call visible if its value is true then diplay this node else don't display thid node, but this condition i am able to check using xpath in asp.net 2.0 till MenuItem node. if i check visible attribute value till SubMenuLevel0 node then in tree it will not display the MenuItem Node at all Note: My tree Menu will start from MenuItem node and it will...
8
2097
by: gs | last post by:
I was able to set tooltips on objects other than main menu. I would like to get the effect of tooltip or microhelp in the bottom status bar when the mouse is hovering over a submenu item. How do I do that? For example in outlook express, when one expand a main menu item and holds mouse over one of the enable sub menu item, one would see some sort microhelp text in the status bar in the bottom
1
3742
by: bruce628 | last post by:
I want to use SWT Label and popmenu to construct a menubar ,and the effect of this menubar is same to the menubar in SWT.When click the Label,it should be highlighted and popmenu shows.The issue is when click the label and move the mouse to enter next label,the next label can not be highlighted.Can anyone have a solution for it? Here is my code: import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.*; public class labelmenu { ...
2
2262
by: Ravi Joshi | last post by:
The menu on my site works fine in IE6 and Firefox. In IE7, there is a problem with the menu: when you mouse over the various main catagories, the sub-catagories all appear to the right as they should; however, as soon as you mouse towards any but the TOP sub-catagory, all those sub-catagories still view there. It will work first time quite fine..but if user clicks outsite anywhere in screen then this problem occur.. i think it's css...
0
3129
by: mjohnson0321 | last post by:
I am trying to incorporate a CSS drop-down menu into a site (suckerfish menu). The menu gets lost behind the content below it, but only on one of the drop downs (News). The error occurs on all of the browsers I have tested it on (IE6, IE7, Firefox, Opera and Safari). It is probably something simple, but I can't find it! Here is the CSS (using external style sheets): style-temp.css (Main style sheet for the site): * { font-family:...
1
2700
by: SunshineInTheRain | last post by:
The following code is dynamic create dropdownmenu which data within pulled from database However, the code work well on IE but not on Firefox. On Firefox, the whole mouseover and mouseout function din't work. what is not supported on Firefox? the javascript syntax? please help as i am not familiar with javascript. thanks in advanced. this is quite urgent.... please.. By the way hope there has somebody may help me find out why the design may...
0
7979
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7894
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6706
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3893
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3937
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2409
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.