|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
tootip or microhelp for menu itemsI 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 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? Show quoteHide quote "gs" <gs@dontMail.telus> wrote in message news:uLu%23tGe$GHA.4328@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 >
Show quote
Hide quote
"gs" <gs@dontMail.telus> wrote in message I'm not exactly sure if these are the same requests. Here is how to display news:Oets1ee$GHA.3572@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.telus> wrote in message > news:uLu%23tGe$GHA.4328@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 >> > 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 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. Show quoteHide quote "RobinS" <RobinS@NoSpam.yah.none> wrote in message news:g6qdnaPQ-vSK3tfYnZ2dnUVZ_tydnZ2d@comcast.com... > > "gs" <gs@dontMail.telus> wrote in message > news:Oets1ee$GHA.3572@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.telus> wrote in message > > news:uLu%23tGe$GHA.4328@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 > > 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. Show quoteHide quote "GS" <gsmsnews.microsoft.co***@msnews.Nomail.com> wrote in message news:O9PqXAKAHHA.1224@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" <RobinS@NoSpam.yah.none> wrote in message > news:g6qdnaPQ-vSK3tfYnZ2dnUVZ_tydnZ2d@comcast.com... >> >> "gs" <gs@dontMail.telus> wrote in message >> news:Oets1ee$GHA.3572@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.telus> wrote in message >> > news:uLu%23tGe$GHA.4328@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 >> >> > > 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. why> eventually I would want the menu text be from resource file for multi-language interface. Show quoteHide quote "RobinS" <RobinS@NoSpam.yah.none> wrote in message news:1dednbNz6MkbqNPYnZ2dnUVZ_qmdnZ2d@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" <gsmsnews.microsoft.co***@msnews.Nomail.com> wrote in message > news:O9PqXAKAHHA.1224@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" <RobinS@NoSpam.yah.none> wrote in message > > news:g6qdnaPQ-vSK3tfYnZ2dnUVZ_tydnZ2d@comcast.com... > >> > >> "gs" <gs@dontMail.telus> wrote in message > >> news:Oets1ee$GHA.3572@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.telus> wrote in message > >> > news:uLu%23tGe$GHA.4328@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 > >> > >> > > > > > > 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. Show quoteHide quote "GS" <gsmsnews.microsoft.co***@msnews.Nomail.com> wrote in message news:%23QqoljiAHHA.3620@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. > why> eventually I would want the menu text be from resource file for > multi-language interface. > > > > > "RobinS" <RobinS@NoSpam.yah.none> wrote in message > news:1dednbNz6MkbqNPYnZ2dnUVZ_qmdnZ2d@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" <gsmsnews.microsoft.co***@msnews.Nomail.com> wrote in message >> news:O9PqXAKAHHA.1224@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" <RobinS@NoSpam.yah.none> wrote in message >> > news:g6qdnaPQ-vSK3tfYnZ2dnUVZ_tydnZ2d@comcast.com... >> >> >> >> "gs" <gs@dontMail.telus> wrote in message >> >> news:Oets1ee$GHA.3572@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.telus> wrote in message >> >> > news:uLu%23tGe$GHA.4328@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 >> >> >> >> >> > >> > >> >> > > 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 --------------------------------- Show quoteHide quote "RobinS" <RobinS@NoSpam.yah.none> wrote in message news:T9ydnXxOT5tKj83YnZ2dnUVZ_rCdnZ2d@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" <gsmsnews.microsoft.co***@msnews.Nomail.com> wrote in message > news:%23QqoljiAHHA.3620@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. >> why> eventually I would want the menu text be from resource file for >> multi-language interface. >> >> >> >> >> "RobinS" <RobinS@NoSpam.yah.none> wrote in message >> news:1dednbNz6MkbqNPYnZ2dnUVZ_qmdnZ2d@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" <gsmsnews.microsoft.co***@msnews.Nomail.com> wrote in message >>> news:O9PqXAKAHHA.1224@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" <RobinS@NoSpam.yah.none> wrote in message >>> > news:g6qdnaPQ-vSK3tfYnZ2dnUVZ_tydnZ2d@comcast.com... >>> >> >>> >> "gs" <gs@dontMail.telus> wrote in message >>> >> news:Oets1ee$GHA.3572@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.telus> wrote in message >>> >> > news:uLu%23tGe$GHA.4328@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 >>> >> >>> >> >>> > >>> > >>> >>> >> >> > > Great! Thank you very much
Show quoteHide quote "RobinS" <RobinS@NoSpam.yah.none> wrote in message news:zIydnQiswuO1sMzYnZ2dnUVZ_uOdnZ2d@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" <RobinS@NoSpam.yah.none> wrote in message > news:T9ydnXxOT5tKj83YnZ2dnUVZ_rCdnZ2d@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" <gsmsnews.microsoft.co***@msnews.Nomail.com> wrote in message > > news:%23QqoljiAHHA.3620@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. > >> why> eventually I would want the menu text be from resource file for > >> multi-language interface. > >> > >> > >> > >> > >> "RobinS" <RobinS@NoSpam.yah.none> wrote in message > >> news:1dednbNz6MkbqNPYnZ2dnUVZ_qmdnZ2d@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" <gsmsnews.microsoft.co***@msnews.Nomail.com> wrote in message > >>> news:O9PqXAKAHHA.1224@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" <RobinS@NoSpam.yah.none> wrote in message > >>> > news:g6qdnaPQ-vSK3tfYnZ2dnUVZ_tydnZ2d@comcast.com... > >>> >> > >>> >> "gs" <gs@dontMail.telus> wrote in message > >>> >> news:Oets1ee$GHA.3572@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.telus> wrote in message > >>> >> > news:uLu%23tGe$GHA.4328@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 > >>> >> > >>> >> > >>> > > >>> > > >>> > >>> > >> > >> > > > > > >
NULL dates show today's date rather than a blank or NULL on form
NewBie start a windows service remotely Trouble with a console app Scoping Issues line replacing ideas Looking for online articles/tutorials or good reference books Write an XML node Auto Gen Properties from fields DropDownList Refuses To Show New SelectedValue |
|||||||||||||||||||||||