By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,515 Members | 1,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,515 IT Pros & Developers. It's quick & easy.

tootip or microhelp for menu items

P: n/a
gs
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
Nov 1 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
gs
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?
"gs" <gs@dontMail.teluswrote in message
news:uL****************@TK2MSFTNGP03.phx.gbl...
>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

Nov 1 '06 #2

P: n/a

"gs" <gs@dontMail.teluswrote in message
news:Oe**************@TK2MSFTNGP02.phx.gbl...
>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?
"gs" <gs@dontMail.teluswrote in message
news:uL****************@TK2MSFTNGP03.phx.gbl...
>>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
Nov 2 '06 #3

P: n/a
GS
thank you.

I tired to deal with next level but failed as toolStripItem does not have
dropdownItems, neither does menuStripItems.

I tried ctype but did not get to work either. all I need now is one more
level for ToolStripMenuItems.

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:g6******************************@comcast.com. ..
>
"gs" <gs@dontMail.teluswrote in message
news:Oe**************@TK2MSFTNGP02.phx.gbl...
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?
"gs" <gs@dontMail.teluswrote in message
news:uL****************@TK2MSFTNGP03.phx.gbl...
>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


Nov 5 '06 #4

P: n/a
You're right; I tried to figure out how to do it, but it's not
inherently obvious. I've searched all over, and can't find
anything that tells how to enumerate through all the items
in all the levels of a MenuStrip.

Why don't you use tooltips instead? If you enable the property
"Show Item Tooltips" for the Menu Strip, and then fill in the
tool tips for each option, they will be displayed when you hover
over the menu option.

The only other thing I can think of is to add the options to
the menustrip programmatically, and as you do that, add the
events.

Good Luck.
Robin S.
"GS" <gs**********************@msnews.Nomail.comwrote in message
news:O9**************@TK2MSFTNGP04.phx.gbl...
thank you.

I tired to deal with next level but failed as toolStripItem does not have
dropdownItems, neither does menuStripItems.

I tried ctype but did not get to work either. all I need now is one more
level for ToolStripMenuItems.

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:g6******************************@comcast.com. ..
>>
"gs" <gs@dontMail.teluswrote in message
news:Oe**************@TK2MSFTNGP02.phx.gbl...
>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?
"gs" <gs@dontMail.teluswrote in message
news:uL****************@TK2MSFTNGP03.phx.gbl...
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



Nov 5 '06 #5

P: n/a
GS
Thank you. Now that I have fully converted to menuStrip with
ToolStripMenuItems and that I was finally find the tooltips, I am using
tooltips.

For now the tooltips is good

Nonetheless I would love to find out how to iterate through all the items.
whyeventually I would want the menu text be from resource file for
multi-language interface.


"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:1d******************************@comcast.com. ..
You're right; I tried to figure out how to do it, but it's not
inherently obvious. I've searched all over, and can't find
anything that tells how to enumerate through all the items
in all the levels of a MenuStrip.

Why don't you use tooltips instead? If you enable the property
"Show Item Tooltips" for the Menu Strip, and then fill in the
tool tips for each option, they will be displayed when you hover
over the menu option.

The only other thing I can think of is to add the options to
the menustrip programmatically, and as you do that, add the
events.

Good Luck.
Robin S.
"GS" <gs**********************@msnews.Nomail.comwrote in message
news:O9**************@TK2MSFTNGP04.phx.gbl...
thank you.

I tired to deal with next level but failed as toolStripItem does not
have
dropdownItems, neither does menuStripItems.

I tried ctype but did not get to work either. all I need now is one
more
level for ToolStripMenuItems.

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:g6******************************@comcast.com. ..
>
"gs" <gs@dontMail.teluswrote in message
news:Oe**************@TK2MSFTNGP02.phx.gbl...
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?
"gs" <gs@dontMail.teluswrote in message
news:uL****************@TK2MSFTNGP03.phx.gbl...
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



Nov 7 '06 #6

P: n/a
I'm glad that worked for you, the tooltips I mean. I would
also like to know how to iterate all the down, and if I ever
figure it out, I'll post it here just for grins.

I thought I saw something in a MSFT article that said
something about using ReadNext to go through them, but
couldn't find it again, so maybe I dreamed it.

Like I said before, the only other thing I could think of
is if you could build the menu from scratch and add the
eventhandlers as you go. What a pain.

You could certainly read the menu info from a file and
create the menu from scratch, complete with the tooltips,
in different languages. Seems like that would be the
kind of thing you'd want to look into that CultureInfo
class for.

Good luck.
Robin S.

"GS" <gs**********************@msnews.Nomail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Thank you. Now that I have fully converted to menuStrip with
ToolStripMenuItems and that I was finally find the tooltips, I am using
tooltips.

For now the tooltips is good

Nonetheless I would love to find out how to iterate through all the items.
whyeventually I would want the menu text be from resource file for
multi-language interface.


"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:1d******************************@comcast.com. ..
>You're right; I tried to figure out how to do it, but it's not
inherently obvious. I've searched all over, and can't find
anything that tells how to enumerate through all the items
in all the levels of a MenuStrip.

Why don't you use tooltips instead? If you enable the property
"Show Item Tooltips" for the Menu Strip, and then fill in the
tool tips for each option, they will be displayed when you hover
over the menu option.

The only other thing I can think of is to add the options to
the menustrip programmatically, and as you do that, add the
events.

Good Luck.
Robin S.
"GS" <gs**********************@msnews.Nomail.comwrote in message
news:O9**************@TK2MSFTNGP04.phx.gbl...
thank you.

I tired to deal with next level but failed as toolStripItem does not
have
dropdownItems, neither does menuStripItems.

I tried ctype but did not get to work either. all I need now is one
more
level for ToolStripMenuItems.

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:g6******************************@comcast.com. ..

"gs" <gs@dontMail.teluswrote in message
news:Oe**************@TK2MSFTNGP02.phx.gbl...
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?
"gs" <gs@dontMail.teluswrote in message
news:uL****************@TK2MSFTNGP03.phx.gbl...
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




Nov 7 '06 #7

P: n/a
I got this is from PamelaFluente, and wanted to
post it as a response here in case you don't see
the other posting. The answer to your question
is below.
Thanks again to Pamela.
Robin S
-----------------------------------

Private Sub AddMenuStripEventHandlers(ByVal msMenuStrip As MenuStrip)
RecurseItems(Me.MenuStrip.Items)
End Sub

Sub RecurseItems(ByVal ToolStripItemCollection As ToolStripItemCollection)
Try
For Each ToolStripMenuItemChild As ToolStripMenuItem _
In ToolStripItemCollection
'Debug.Print("I am on " & ToolStripMenuItemChild.Text)
If ToolStripMenuItemChild.Tag IsNot Nothing Then
AddHandler ToolStripMenuItemChild.MouseEnter, _
AddressOf MenuItem_MouseEnter
AddHandler ToolStripMenuItemChild.MouseLeave, _
AddressOf MenuItem_MouseLeave
End If
RecurseItems(ToolStripMenuItemChild.DropDownItems)
Next ToolStripMenuItemChild
Catch ex As InvalidCastException
'ignore it; you'll get this for the separator lines
End Try
End Sub

---------------------------------

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:T9******************************@comcast.com. ..
I'm glad that worked for you, the tooltips I mean. I would
also like to know how to iterate all the down, and if I ever
figure it out, I'll post it here just for grins.

I thought I saw something in a MSFT article that said
something about using ReadNext to go through them, but
couldn't find it again, so maybe I dreamed it.

Like I said before, the only other thing I could think of
is if you could build the menu from scratch and add the
eventhandlers as you go. What a pain.

You could certainly read the menu info from a file and
create the menu from scratch, complete with the tooltips,
in different languages. Seems like that would be the
kind of thing you'd want to look into that CultureInfo
class for.

Good luck.
Robin S.

"GS" <gs**********************@msnews.Nomail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>Thank you. Now that I have fully converted to menuStrip with
ToolStripMenuItems and that I was finally find the tooltips, I am using
tooltips.

For now the tooltips is good

Nonetheless I would love to find out how to iterate through all the
items.
whyeventually I would want the menu text be from resource file for
multi-language interface.


"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:1d******************************@comcast.com ...
>>You're right; I tried to figure out how to do it, but it's not
inherently obvious. I've searched all over, and can't find
anything that tells how to enumerate through all the items
in all the levels of a MenuStrip.

Why don't you use tooltips instead? If you enable the property
"Show Item Tooltips" for the Menu Strip, and then fill in the
tool tips for each option, they will be displayed when you hover
over the menu option.

The only other thing I can think of is to add the options to
the menustrip programmatically, and as you do that, add the
events.

Good Luck.
Robin S.
"GS" <gs**********************@msnews.Nomail.comwrote in message
news:O9**************@TK2MSFTNGP04.phx.gbl...
thank you.

I tired to deal with next level but failed as toolStripItem does not
have
>dropdownItems, neither does menuStripItems.

I tried ctype but did not get to work either. all I need now is one
more
>level for ToolStripMenuItems.

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:g6******************************@comcast.com ...

"gs" <gs@dontMail.teluswrote in message
news:Oe**************@TK2MSFTNGP02.phx.gbl...
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?
"gs" <gs@dontMail.teluswrote in message
news:uL****************@TK2MSFTNGP03.phx.gbl...
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




Nov 8 '06 #8

P: n/a
GS
Great! Thank you very much
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:zI******************************@comcast.com. ..
I got this is from PamelaFluente, and wanted to
post it as a response here in case you don't see
the other posting. The answer to your question
is below.
Thanks again to Pamela.
Robin S
-----------------------------------

Private Sub AddMenuStripEventHandlers(ByVal msMenuStrip As MenuStrip)
RecurseItems(Me.MenuStrip.Items)
End Sub

Sub RecurseItems(ByVal ToolStripItemCollection As ToolStripItemCollection)
Try
For Each ToolStripMenuItemChild As ToolStripMenuItem _
In ToolStripItemCollection
'Debug.Print("I am on " & ToolStripMenuItemChild.Text)
If ToolStripMenuItemChild.Tag IsNot Nothing Then
AddHandler ToolStripMenuItemChild.MouseEnter, _
AddressOf MenuItem_MouseEnter
AddHandler ToolStripMenuItemChild.MouseLeave, _
AddressOf MenuItem_MouseLeave
End If
RecurseItems(ToolStripMenuItemChild.DropDownItems)
Next ToolStripMenuItemChild
Catch ex As InvalidCastException
'ignore it; you'll get this for the separator lines
End Try
End Sub

---------------------------------

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:T9******************************@comcast.com. ..
I'm glad that worked for you, the tooltips I mean. I would
also like to know how to iterate all the down, and if I ever
figure it out, I'll post it here just for grins.

I thought I saw something in a MSFT article that said
something about using ReadNext to go through them, but
couldn't find it again, so maybe I dreamed it.

Like I said before, the only other thing I could think of
is if you could build the menu from scratch and add the
eventhandlers as you go. What a pain.

You could certainly read the menu info from a file and
create the menu from scratch, complete with the tooltips,
in different languages. Seems like that would be the
kind of thing you'd want to look into that CultureInfo
class for.

Good luck.
Robin S.

"GS" <gs**********************@msnews.Nomail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Thank you. Now that I have fully converted to menuStrip with
ToolStripMenuItems and that I was finally find the tooltips, I am using
tooltips.

For now the tooltips is good

Nonetheless I would love to find out how to iterate through all the
items.
whyeventually I would want the menu text be from resource file for
multi-language interface.


"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:1d******************************@comcast.com. ..
You're right; I tried to figure out how to do it, but it's not
inherently obvious. I've searched all over, and can't find
anything that tells how to enumerate through all the items
in all the levels of a MenuStrip.

Why don't you use tooltips instead? If you enable the property
"Show Item Tooltips" for the Menu Strip, and then fill in the
tool tips for each option, they will be displayed when you hover
over the menu option.

The only other thing I can think of is to add the options to
the menustrip programmatically, and as you do that, add the
events.

Good Luck.
Robin S.
"GS" <gs**********************@msnews.Nomail.comwrote in message
news:O9**************@TK2MSFTNGP04.phx.gbl...
thank you.

I tired to deal with next level but failed as toolStripItem does not
have
dropdownItems, neither does menuStripItems.

I tried ctype but did not get to work either. all I need now is
one
more
level for ToolStripMenuItems.

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:g6******************************@comcast.com. ..

"gs" <gs@dontMail.teluswrote in message
news:Oe**************@TK2MSFTNGP02.phx.gbl...
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?
"gs" <gs@dontMail.teluswrote in message
news:uL****************@TK2MSFTNGP03.phx.gbl...
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





Nov 9 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.