|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Text PopupI have a listbox with a list of commands. When I put the mouse over
each element I want a small text box to pop-up with help commands. I dont' want to click the mouse - just overlay it. Hardy HardySpicer wrote:
> I have a listbox with a list of commands. When I put the mouse over You are talking about tool tips.> each element I want a small text box to pop-up with help commands. I > dont' want to click the mouse - just overlay it. Here is a function to add to your form class: Private _tip As New System.Windows.Forms.ToolTip() Public Sub DynoTip( _ ByVal sender As System.Object, _ Byval Title as String, _ Byval text as string) ' Set up the delays for the ToolTip. _tip.AutoPopDelay = 15000 _tip.InitialDelay = 1000 _tip.ReshowDelay = 500 _tip.UseFading = True _tip.ShowAlways = True _tip.ToolTipTitle = title _tip.Show(text, _ sender, _ New System.Drawing.Point(0, sender.Height), 5000) End Sub Usage: DynoTip(sender, "My Title", "text in box") now, the trick for what you want is to probably going to require a MouseHover or MoustCaptureChanged event over the listbox or as I just tried the SelectedIndexChanged event with a CheckedListBox: Private Sub CheckedListBox1_SelectedIndexChanged( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles _ CheckedListBox1.SelectedIndexChanged Dim i As Integer = CheckedListBox1.SelectedIndex If i >= 0 Then Dim title As String = _ CheckedListBox1.Items().Item(i).ToString BalloonTipIcon1.DynoTip(sender, title, _ "help for " + title) End If End Sub If you want it to just to hover without any select, then you have to play with the MouseHover and I can imagine that will be alittle tricky to work out the IN/OUT timing. That should get your started to fine tune it. -- thank you it's very usefull
Show quoteHide quote "Mike" <unkn***@unknown.tv> a écrit dans le message de groupe de discussion : #uorjD75JHA.6***@TK2MSFTNGP02.phx.gbl... > HardySpicer wrote: >> I have a listbox with a list of commands. When I put the mouse over >> each element I want a small text box to pop-up with help commands. I >> dont' want to click the mouse - just overlay it. > > You are talking about tool tips. > > Here is a function to add to your form class: > > Private _tip As New System.Windows.Forms.ToolTip() > Public Sub DynoTip( _ > ByVal sender As System.Object, _ > Byval Title as String, _ > Byval text as string) > ' Set up the delays for the ToolTip. > _tip.AutoPopDelay = 15000 > _tip.InitialDelay = 1000 > _tip.ReshowDelay = 500 > _tip.UseFading = True > _tip.ShowAlways = True > _tip.ToolTipTitle = title > _tip.Show(text, _ > sender, _ > New System.Drawing.Point(0, sender.Height), 5000) > End Sub > > Usage: > > DynoTip(sender, "My Title", "text in box") > > now, the trick for what you want is to probably going to require a > MouseHover or MoustCaptureChanged event over the listbox or as I just > tried the SelectedIndexChanged event with a CheckedListBox: > > Private Sub CheckedListBox1_SelectedIndexChanged( _ > ByVal sender As System.Object, _ > ByVal e As System.EventArgs) Handles _ > CheckedListBox1.SelectedIndexChanged > > Dim i As Integer = CheckedListBox1.SelectedIndex > If i >= 0 Then > Dim title As String = _ > CheckedListBox1.Items().Item(i).ToString > BalloonTipIcon1.DynoTip(sender, title, _ > "help for " + title) > End If > End Sub > > If you want it to just to hover without any select, then you have to play > with the MouseHover and I can imagine that will be alittle tricky to work > out the IN/OUT timing. > > That should get your started to fine tune it. > > -- On Jun 8, 8:45 am, Mike <unkn***@unknown.tv> wrote:
Show quoteHide quote > HardySpicer wrote: So I am guessing that I need an array of some sort with all my help> > I have a listbox with a list of commands. When I put the mouse over > > each element I want a small text box to pop-up with help commands. I > > dont' want to click the mouse - just overlay it. > > You are talking about tool tips. > > Here is a function to add to your form class: > > Private _tip As New System.Windows.Forms.ToolTip() > Public Sub DynoTip( _ > ByVal sender As System.Object, _ > Byval Title as String, _ > Byval text as string) > ' Set up the delays for the ToolTip. > _tip.AutoPopDelay = 15000 > _tip.InitialDelay = 1000 > _tip.ReshowDelay = 500 > _tip.UseFading = True > _tip.ShowAlways = True > _tip.ToolTipTitle = title > _tip.Show(text, _ > sender, _ > New System.Drawing.Point(0, sender..Height), 5000) > End Sub > > Usage: > > DynoTip(sender, "My Title", "text in box") > > now, the trick for what you want is to probably going to require a > MouseHover or MoustCaptureChanged event over the listbox or as I just > tried the SelectedIndexChanged event with a CheckedListBox: > > Private Sub CheckedListBox1_SelectedIndexChanged( _ > ByVal sender As System.Object, _ > ByVal e As System.EventArgs) Handles _ > CheckedListBox1.SelectedIndexChanged > > Dim i As Integer = CheckedListBox1.SelectedIndex > If i >= 0 Then > Dim title As String = _ > CheckedListBox1.Items().Item(i).ToString > BalloonTipIcon1.DynoTip(sender, title, _ > "help for " + title) > End If > End Sub > > If you want it to just to hover without any select, then you have to > play with the MouseHover and I can imagine that will be alittle tricky > to work out the IN/OUT timing. > > That should get your started to fine tune it. > > -- commands so I can index each one. Works great! Thanks Hardy "HardySpicer" <gyansor***@gmail.com> wrote in message Mike's solution is interesting. Here would be the next step to that, in my news:cdc5be5d-a552-401d-93b4-e76d602e5e92@s16g2000vbp.googlegroups.com... >I have a listbox with a list of commands. When I put the mouse over > each element I want a small text box to pop-up with help commands. I > dont' want to click the mouse - just overlay it. > > > Hardy opinion. I would do this: Add an event handler for the listbox mousemove event in your constructor, like this: AddHandler ListBox1.MouseMove, AddressOf MyTooltipHandler Then have the handler coded like this: Public Sub MyTooltipHandler(ByVal sender As Object, ByVal mmea As MouseEventArgs) Dim p As Point = Cursor.Position p = ListBox1.PointToClient(p) Dim idx As Integer idx = p.Y / ListBox1.ItemHeight If (idx < ListBox1.Items.Count) Then ToolTip1.SetToolTip(ListBox1, ListBox1.Items(idx)) Else ToolTip1.SetToolTip(ListBox1, "Unkown") End If End Sub -- Mike
My.Settings Questions
heredoc-like syntax in VB.Net? Too many items in listbox? RichTextBox How to pass a structure to a form subroutine Enable/Disable Checkboxes based on Parent Check value? Copying Windows Form to another project Odd problem with Me.Hide() and Me.Visible = False Extarcting email attachmnets from exchange How to access a scanner in VB.NET |
|||||||||||||||||||||||