Kurt Posted July 31, 2003 Posted July 31, 2003 I just had a first look at the tooltip class. The only example given is .... Private Sub CreateMyToolTip2() ' Create the ToolTip and associate with the Form container. Dim toolTip1 As New ToolTip(Me.components) ' Set up the delays for the ToolTip. toolTip1.AutoPopDelay = 5000 toolTip1.InitialDelay = 1000 toolTip1.ReshowDelay = 500 ' Force the ToolTip text to be displayed whether or not the form is active. toolTip1.ShowAlways = True ' Set up the ToolTip text for the Button. toolTip1.SetToolTip(Me.Button1, "My button1") End Sub some questions and remarks: 1/ If I call the sub, I get an error 'Object reference not set to an instance of an object', and indeed, Me.components is not declared with the New() keyword. But it's an interface (System.ComponentModel.IContainer) and I don't think it's possible to create an instance of an interface using New().??? Anyways, I 'm not very home in these matters, but Dim toolTip1 As New ToolTip() does the trick, and associates by default the tooltip class to the container that is creating the instance... 2/ Suppose I would like to change the tooltip text of a control runtime, do I then have to declare a global instance of the tooltip class, so I can access it after the sub is finished? In this piece of code I would expect that the object ToolTip1 is ready to be collected by the garbage collector after the sub is finished. Still, the tooltip for the button is shown... It's even possible to attach a second tooltip to button1 by calling CreateMyToolTip2 Private Sub CreateMyToolTip2() ' Create the ToolTip and associate with the Form container. Dim toolTip1 As New ToolTip() ' Set up the delays for the ToolTip. toolTip1.AutoPopDelay = 5000 toolTip1.InitialDelay = 100 toolTip1.ReshowDelay = 500 ' Force the ToolTip text to be displayed whether or not the form is active. toolTip1.ShowAlways = True ' Set up the ToolTip text for the Button. toolTip1.SetToolTip(Me.Button1, "Also My Button 1") End Sub Can someone clear out what actually is going on? Quote qrt
*Gurus* divil Posted July 31, 2003 *Gurus* Posted July 31, 2003 1) This is correct, you don't actually need the ToolTip to be a part of a container for it to work just fine. 2) Yes, you ideally want the same instance to be around, so you'll have to declare it at form-level scope and use its SetToolTip method on the same control as many times as you like. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Diablicolic Posted August 3, 2003 Posted August 3, 2003 What exactly is a tool tip? :confused: Quote "Reality is fake, Dreams are for real"
wyrd Posted August 3, 2003 Posted August 3, 2003 Hover your mouse over one of the graphical buttons on this web page for a few seconds. It'll pop up with a little message saying what the button is for. That's a tooltip. Quote Gamer extraordinaire. Programmer wannabe.
Diablicolic Posted August 3, 2003 Posted August 3, 2003 Oh sweet, I could use this! :p Quote "Reality is fake, Dreams are for real"
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.