469,601 Members | 2,450 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,601 developers. It's quick & easy.

Statusbar and menu

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.Viswanathan
Aug 8 '07 #1
3 2204
Example originally from Microsoft
http://home.comcast.net/~kevininstru...nu_Example.zip

"S. Viswanathan" <vi**@ewaksoft.comwrote in message
news:%2***************@TK2MSFTNGP06.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.Viswanathan


Aug 8 '07 #2
There are much better ways of doing it...

http://forums.microsoft.com/MSDN/Sho...32007&SiteID=1

better way to do it... make an IExtenderProvider that extends the menu items
and/or toolstrip items or other objects to handle this
"ke*************@state.or.us" <Ke***************@state.or.uswrote in
message news:OE**************@TK2MSFTNGP02.phx.gbl...
Example originally from Microsoft
http://home.comcast.net/~kevininstru...nu_Example.zip

"S. Viswanathan" <vi**@ewaksoft.comwrote in message
news:%2***************@TK2MSFTNGP06.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.Viswanathan



Aug 9 '07 #3
I like it although it is flawed in SetStatusMessage.

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(False)unless someone else knows how to fix this issue.
Otherwise an excellent idea.

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
<System.Drawing.ToolboxBitmap(GetType(System.Windo ws.Forms.StatusBar))_
<ProvideProperty("StatusMessage", GetType(Component))_
<Description("Tool tip to display in your statusbar")_
Public Class StatusMessage
Inherits Component
Implements IExtenderProvider

Dim mControlLookup As Hashtable = New Hashtable
Dim mLastMessage As String = String.Empty
Public Sub SetStatusMessage(ByVal senderComponent As Component, ByVal
strMessage As String)
If Not mControlLookup.Contains(senderComponent) Then
mControlLookup.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
' Bug
mControlLookup(senderComponent) = strMessage
End If
End If
End Sub
Public Function GetStatusMessage(ByVal senderComponent As Component) As
String
If mControlLookup.Contains(senderComponent) Then
Return mControlLookup(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 mStatusBar As ToolStripStatusLabel

Public Property StatusBar() As ToolStripStatusLabel
Get
Return mStatusBar
End Get
Set(ByVal value As ToolStripStatusLabel)
mStatusBar = 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 mControlLookup.Contains(pControl) Then
If Not mControlLookup(pControl).ToString.Trim = String.Empty Then
StatusBar.Text = mControlLookup(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.mLastMessage
End Sub

Private Sub Handle_MenuEnter(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**************@TK2MSFTNGP05.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 IExtenderProvider that extends the menu
items and/or toolstrip items or other objects to handle this
"ke*************@state.or.us" <Ke***************@state.or.uswrote in
message news:OE**************@TK2MSFTNGP02.phx.gbl...
>Example originally from Microsoft
http://home.comcast.net/~kevininstru...nu_Example.zip

"S. Viswanathan" <vi**@ewaksoft.comwrote in message
news:%2***************@TK2MSFTNGP06.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.Viswanathan




Aug 9 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Tonya | last post: by
18 posts views Thread by Andrew Poulos | last post: by
1 post views Thread by Ahmet | last post: by
6 posts views Thread by Anony | last post: by
14 posts views Thread by Kishan Hathiwala | last post: by
1 post views Thread by herve | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.