469,924 Members | 1,428 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,924 developers. It's quick & easy.

Show ToolTip on every Control continuously

Hi,

Using VB.NET 2.0, Windows Forms.
I want the ToolTip to be shown on every TextBox, ComboBox and DataGridView
continuously, and show the contence of these controls. Is there a way to add
the ToolTip automaticly for all these controls, without having to link it
the whole time to them for every new Control I put on my Forms?

And regarding the DataGridView: The ToolTip doesn't show the whole value of
every Cell, but cuts it off when it's too long. how to get around this?

Thansk a lot in advance,

Pieter
Oct 19 '06 #1
4 3329
You could use a label.

T

Pieter wrote:
>Hi,

Using VB.NET 2.0, Windows Forms.
I want the ToolTip to be shown on every TextBox, ComboBox and DataGridView
continuously, and show the contence of these controls. Is there a way to add
the ToolTip automaticly for all these controls, without having to link it
the whole time to them for every new Control I put on my Forms?

And regarding the DataGridView: The ToolTip doesn't show the whole value of
every Cell, but cuts it off when it's too long. how to get around this?

Thansk a lot in advance,

Pieter

Oct 19 '06 #2
Hi Pieter,

For automatically initializing all tooltip for all the components on
your form try calling this procedure from the Form1_load event:

Private Sub SetToolTips()
Dim i As Control
For Each i In Me.Controls
ToolTip1.SetToolTip(i,
i.ToString.Substring(i.ToString.IndexOf("Text:") + 5))
Next
End Sub

If you test this with the caption just "i.tostring", you'll see why I
parsed the control.tostring in this way.

I'm not sure if there is a less intensive way to automatically update
the tooltip text in the event of a change without writing an individual
event handler for each control.

Regarding the DataGridView cells question, I'm not sure what you mean.
What are you trying to do, and what does the application show? Are you
building the Tooltip caption?

Regards,
Keith

Pieter wrote:
Hi,

Using VB.NET 2.0, Windows Forms.
I want the ToolTip to be shown on every TextBox, ComboBox and DataGridView
continuously, and show the contence of these controls. Is there a way to add
the ToolTip automaticly for all these controls, without having to link it
the whole time to them for every new Control I put on my Forms?

And regarding the DataGridView: The ToolTip doesn't show the whole value of
every Cell, but cuts it off when it's too long. how to get around this?

Thansk a lot in advance,

Pieter
Oct 19 '06 #3
I don't think what you want to do is possible. The Tooltip window is usually
a single instance of a simple window that shows a string which it gets by
looking at a record in a hashtable which is associated with a control. To
show a whole lot of windows from this one object and to show more than one
string at a time is pretty well impossible.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Pieter" <pi****************@hotmail.comwrote in message
news:ui**************@TK2MSFTNGP04.phx.gbl...
Hi,

Using VB.NET 2.0, Windows Forms.
I want the ToolTip to be shown on every TextBox, ComboBox and DataGridView
continuously, and show the contence of these controls. Is there a way to
add the ToolTip automaticly for all these controls, without having to link
it the whole time to them for every new Control I put on my Forms?

And regarding the DataGridView: The ToolTip doesn't show the whole value
of every Cell, but cuts it off when it's too long. how to get around this?

Thansk a lot in advance,

Pieter

Oct 19 '06 #4

This would work well unless the control is belong to a secondary
container like Panel or GroupBox. I guess that you don't want to show
tooltip for every control (like Panel, etc.) so you may need some "if"s
inside. Something like the following would do the job:

Private Sub SetToolTips(ByVal ctrl as Control)
{
if typeof ctrl is Form OrElse typeof ctrl is Panel OrElse ... then
' do nothing
else if typeof ctrl is DataGridView/listview/treeview then
' do something as per requirements
else ' other control, just set text
toolTip1.SetToolTip(ctrl, ctrl.Text);
end if

for each child as Control in ctrl.Controls
SetToolTips(child) ' recursive
next
}

Then, in constructor or form load, you could call SetToolTips(Me).

Thi

kgerritsen wrote:
Hi Pieter,

For automatically initializing all tooltip for all the components on
your form try calling this procedure from the Form1_load event:

Private Sub SetToolTips()
Dim i As Control
For Each i In Me.Controls
ToolTip1.SetToolTip(i,
i.ToString.Substring(i.ToString.IndexOf("Text:") + 5))
Next
End Sub

If you test this with the caption just "i.tostring", you'll see why I
parsed the control.tostring in this way.

I'm not sure if there is a less intensive way to automatically update
the tooltip text in the event of a change without writing an individual
event handler for each control.

Regarding the DataGridView cells question, I'm not sure what you mean.
What are you trying to do, and what does the application show? Are you
building the Tooltip caption?

Regards,
Keith

Pieter wrote:
Hi,

Using VB.NET 2.0, Windows Forms.
I want the ToolTip to be shown on every TextBox, ComboBox and DataGridView
continuously, and show the contence of these controls. Is there a way to add
the ToolTip automaticly for all these controls, without having to link it
the whole time to them for every new Control I put on my Forms?

And regarding the DataGridView: The ToolTip doesn't show the whole value of
every Cell, but cuts it off when it's too long. how to get around this?

Thansk a lot in advance,

Pieter
Oct 20 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mr.Tickle | last post: by
3 posts views Thread by RJN | last post: by
reply views Thread by Lucian Wischik | last post: by
2 posts views Thread by Paul E Collins | last post: by
1 post views Thread by tru | last post: by
7 posts views Thread by =?Utf-8?B?U2hhcm9u?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.