473,419 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

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.Collections

Imports System.ComponentModel

Imports System.Windows.Forms

<ProvideProperty("StatusMessage", GetType(Component))> _

Public Class StatusMessage

Inherits Component

Implements IExtenderProvider

Dim ht_ControlLookup As Hashtable = New Hashtable

Dim s_LastMessage As String = String.Empty

Public Sub SetStatusMessage(ByVal senderComponent As Component, ByVal
strMessage As String)

If Not ht_ControlLookup.Contains(senderComponent) Then

ht_ControlLookup.Add(senderComponent, strMessage)

Dim pMenuItem As ToolStripMenuItem = CType(senderComponent,
ToolStripMenuItem)

If pMenuItem IsNot Nothing Then

AddHandler pMenuItem.MouseMove, AddressOf Handle_MenuSelect

AddHandler pMenuItem.MouseLeave, AddressOf Handle_MenuLeave

AddHandler pMenuItem.MouseEnter, AddressOf Handle_MenuEnter

Else

ht_ControlLookup(senderComponent) = strMessage

End If

End If

End Sub

Public Function GetStatusMessage(ByVal senderComponent As Component) As
String

If ht_ControlLookup.Contains(senderComponent) Then

Return ht_ControlLookup(senderComponent).ToString

End If

Return String.Empty

End Function

Public Function CanExtend(ByVal senderComponent As Object) As Boolean
Implements System.ComponentModel.IExtenderProvider.CanExtend

Return TypeOf senderComponent Is ToolStripMenuItem

End Function

Private m_StatusBar As ToolStripStatusLabel

Public Property StatusBar() As ToolStripStatusLabel

Get

Return m_StatusBar

End Get

Set(ByVal value As ToolStripStatusLabel)

m_StatusBar = value

End Set

End Property

Private Sub Handle_MenuSelect(ByVal pControl As Object, ByVal e As
MouseEventArgs)

If StatusBar Is Nothing Then

Exit Sub

End If

If ht_ControlLookup.Contains(pControl) Then

If Not ht_ControlLookup(pControl).ToString.Trim = String.Empty Then

StatusBar.Text = ht_ControlLookup(pControl).ToString

End If

End If

End Sub

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

If StatusBar Is Nothing Then

Exit Sub

End If

StatusBar.Text = Me.s_LastMessage

End Sub

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

If StatusBar Is Nothing Then

Exit Sub

End If

Me.s_LastMessage = StatusBar.Text

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

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

Similar topics

2
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
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...
4
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...
0
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...
8
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...
1
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...
2
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...
0
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...
1
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.