Tooltips only work once on form

S

Steve Cutting

Hi all,

Using the toolbox I added a tooltip provider to my form, and set the text
for each of my buttons using the properties window.

When I first show the form using .showdialog the tooltips work. However
if I close and re-open the form the tooltips are no longer displayed.

Am I missing something obvious or is this a bug ??

thanks in advance
Steve
 
O

One Handed Man \( OHM - Terry Burns \)

Are you using 2003 or 2003, I have no problems on 2003. Also how are you
closing and re-opening the form ?

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
 
S

Steve Cutting

Are you using 2003 or 2003, I have no problems on 2003. Also how are you
closing and re-opening the form ?

Hi Terry,

Using 2003. The form is opened using .showdialog from another form.
Closing via dialogresult.OK/cancel or close button. Just tried me.close as
well. All have the same effect.

The tooltips work with the first .showdialog call but not subsequent ones

thanks
Steve
 
O

One Handed Man \( OHM - Terry Burns \)

I set the same up here and cant re-produce it I am afraid. If you create a
brand new project with Form1 and Form2, calling Form2 from Form1, does this
still fail. It may be that something is corrupted in your project or some
other oddity has occured

Try that first and lets see where we gor from there

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
 
S

Steve Cutting

I set the same up here and cant re-produce it I am afraid. If you create a
brand new project with Form1 and Form2, calling Form2 from Form1, does this
still fail. It may be that something is corrupted in your project or some
other oddity has occured

Try that first and lets see where we gor from there

Yes I just tried that in order to isolate it from my project.

Here is what I just did...

Started a new project
Created form1 with 1 button
Created form2 with 1 button
Added tooltip to form2 and set tooltip text for the button
Put the following in form 1..

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

private f2 as new form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

f2.ShowDialog()

End Sub

End Class


This fails as I have described. form2 will only display the tooltip on the
first open

thanks again
Steve
 
O

One Handed Man \( OHM - Terry Burns \)

Change your code to this and it will work. . . .


private f2 as form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

f2= new Form2
f2.ShowDialog()

End Sub

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
 
S

Steve Cutting

Change your code to this and it will work. . . .


private f2 as form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

f2= new Form2
f2.ShowDialog()

End Sub


Thanks Terry. Yes this works but I don't see why it should be necessary to
instanciate a new form every time. After all a form called with .showdialog
just hides when you close it, and just sits there ready to be opened again.
As such you only need one instance if that's how you're using it.
That's how I use most of the forms in my program, and it's only these
tooltips that have caused problems.

I'm thinking this must just be a bug ??

thanks again
Steve
 
O

One Handed Man \( OHM - Terry Burns \)

When a form is closed, all resources created within the object are closed
and the form is disposed. If you simply want to hide the form from view use
the Hide() method.

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
 
C

Charles Law

Hi Steve

There are undoubtedly problems with the way the tooltip control works. It
has been the subject of some recent threads.

I have had a similar problem, where clicking a button on a form, for
example, stops the tooltip working for that control. I have got round this
by handling the MouseEnter event for each control that has a tooltip, and
explicitly setting the text for the tooltip every time the event fires. It
shouldn't be necessary, but it works, and it may well get round your problem
as well.

HTH

Charles
 
S

Steve Cutting

Hi Steve

There are undoubtedly problems with the way the tooltip control works. It
has been the subject of some recent threads.

I have had a similar problem, where clicking a button on a form, for
example, stops the tooltip working for that control. I have got round this
by handling the MouseEnter event for each control that has a tooltip, and
explicitly setting the text for the tooltip every time the event fires. It
shouldn't be necessary, but it works, and it may well get round your problem
as well.

Thanks Charles. I ended up with the following solution which seems to work.
I just create a new instance of the tooltip in my form_load event. The
tooltips now display as expected for each .showdialog call.

thanks again
Steve


Public Class form2
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

private ToolTip1 as tooltip

Private Sub form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'initialise tooltips
ToolTip1 = New ToolTip
ToolTip1.SetToolTip(button1, "tooltip text 1")
ToolTip1.SetToolTip(button2, "tooltip text 2")

end sub

end class
 
C

Chris Dunaway

When a form is closed, all resources created within the object are closed
and the form is disposed. If you simply want to hide the form from view use
the Hide() method.

I don't believe that the form is disposed when closed after a .showdialog.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
C

Chris Dunaway

I don't believe that the form is disposed when closed after a .showdialog.

Further info from the docs:

When a form is displayed as a modal dialog box, clicking the close form
button (the button with an "X" at the top right of the form) causes the
form to be hidden and the DialogResult property to be set to
DialogResult.Cancel. Unlike modeless forms, the Close method is not called
by the .NET Framework when the user clicks the close form button of a
dialog box or sets the value of the DialogResult property. Instead the form
is hidden and can be shown again without creating a new instance of the
dialog box. Because a form displayed as a dialog box is not closed, you
must call the Dispose method of the form when the form is no longer needed
by your application.


--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top