gs said:
I sort of find a way to make the tag value appear in a status bar but it is
far cry form automatic use of tag.
For each submenu time I have an event handler for select..
will be nice to add select event for submenu item in the instance call and
use the tag. but with the shallow knowledge that I have vb, I don't
have a
clue yet.
any concrete suggestion?
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
I'm not exactly sure if these are the same requests. Here is how to display
status text when someone hovers over the items in a menu strip or toolstrip.
This handles one level of dropdowns; if you have more, you need to use
recursion. Also, this only adds the events when the [tag] property is not
blank, and it displays the tag in the status strip.
You could enable tooltips on the menu items if you want tool tips. That's an
entirely different thing from displaying info in the status strip.
To do this, you need to add handlers for each item for the MouseEnter event
(to set the text) and the MouseLeave event (to blank it back out).
I am calling AddToolStripEventHandlers and AddMenuStripEventHandlers in
my
Form_Load event. You could combine these.
Private Sub AddToolStripEventHandlers(ByVal tsToolStrip As ToolStrip)
For Each item As ToolStripItem In tsToolStrip.Items
If item.Tag IsNot Nothing Then
AddHandler item.MouseEnter, AddressOf MenuItem_MouseEnter
AddHandler item.MouseLeave, AddressOf MenuItem_MouseLeave
End If
Next
End Sub
Private Sub AddMenuStripEventHandlers(ByVal msMenuStrip As MenuStrip)
For Each item As ToolStripMenuItem In msMenuStrip.Items
If item.Tag IsNot Nothing Then
AddHandler item.MouseEnter, AddressOf MenuItem_MouseEnter
AddHandler item.MouseLeave, AddressOf MenuItem_MouseLeave
End If
'if you have dropdown menus inside your dropdown menus,
' you would probably want to make a recursive routine to handle
that
If item.DropDownItems.Count > 0 Then
For i As Integer = 0 To item.DropDownItems.Count - 1
Dim ddItem As ToolStripItem
ddItem = item.DropDownItems(i)
If ddItem.Tag IsNot Nothing Then
AddHandler ddItem.MouseEnter, AddressOf
MenuItem_MouseEnter
AddHandler ddItem.MouseLeave, AddressOf
MenuItem_MouseLeave
End If
Next
End If
Next
End Sub
Private Sub MenuItem_MouseEnter(ByVal sender As Object, ByVal e As
EventArgs)
If TypeOf sender Is ToolStripButton Then
Dim ctrl As ToolStripButton = DirectCast(sender,
ToolStripButton)
Me.ToolStripStatusLabel.Text = ctrl.Tag.ToString
ElseIf TypeOf sender Is ToolStripMenuItem Then
Dim ctrl As ToolStripMenuItem = DirectCast(sender,
ToolStripMenuItem)
Me.ToolStripStatusLabel.Text = ctrl.Tag.ToString
End If
End Sub
Private Sub MenuItem_MouseLeave(ByVal sender As Object, ByVal e As
EventArgs)
Me.ToolStripStatusLabel.Text = String.Empty
End Sub
Robin