I like it although it is flawed in SetStatusMessag e.
1. Add the component, menu and statusbar to a form
2. Create a menu item, set the tool tip.
3. Move off the the propery StatusMessage
4. Move back to the propery and change the text.
5. Move off, the original text is retained.
As coded I would only code the tips via code and mark that propery as
<Browsable(Fals e)unless someone else knows how to fix this issue.
Otherwise an excellent idea.
Imports System
Imports System.Collecti ons
Imports System.Componen tModel
Imports System.Windows. Forms
<System.Drawing .ToolboxBitmap( GetType(System. Windows.Forms.S tatusBar))_
<ProvidePropert y("StatusMessag e", GetType(Compone nt))_
<Description("T ool tip to display in your statusbar")_
Public Class StatusMessage
Inherits Component
Implements IExtenderProvid er
Dim mControlLookup As Hashtable = New Hashtable
Dim mLastMessage As String = String.Empty
Public Sub SetStatusMessag e(ByVal senderComponent As Component, ByVal
strMessage As String)
If Not mControlLookup. Contains(sender Component) Then
mControlLookup. Add(senderCompo nent, 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
' Bug
mControlLookup( senderComponent ) = strMessage
End If
End If
End Sub
Public Function GetStatusMessag e(ByVal senderComponent As Component) As
String
If mControlLookup. Contains(sender Component) Then
Return mControlLookup( senderComponent ).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 mStatusBar As ToolStripStatus Label
Public Property StatusBar() As ToolStripStatus Label
Get
Return mStatusBar
End Get
Set(ByVal value As ToolStripStatus Label)
mStatusBar = 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 mControlLookup. Contains(pContr ol) Then
If Not mControlLookup( pControl).ToStr ing.Trim = String.Empty Then
StatusBar.Text = mControlLookup( pControl).ToStr ing
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.mLastMessage
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.mLastMessage = StatusBar.Text
End Sub
End Class
"Smokey Grindel" <no****@nospam. comwrote in message
news:ud******** ******@TK2MSFTN GP05.phx.gbl...
There are much better ways of doing it...
http://forums.microsoft.com/MSDN/Sho...32007&SiteID=1
better way to do it... make an IExtenderProvid er that extends the menu
items and/or toolstrip items or other objects to handle this
"ke************ *@state.or.us" <Ke************ ***@state.or.us wrote in
message news:OE******** ******@TK2MSFTN GP02.phx.gbl...
>Example originally from Microsoft
http://home.comcast.net/~kevininstru...nu_Example.zip
"S. Viswanathan" <vi**@ewaksoft. comwrote in message
news:%2******* ********@TK2MSF TNGP06.phx.gbl. ..
>>Hi everybody!
In VB.NET 2005, MenuStrip and Statusstrip controls added. When the mouse
over on the Menuitem its corresponding Tooptip text should be displayed
in
the statusstrip.
How to display the statusstrip text while mouseover on the menuitem?
--
Thanks
S.Viswanath an