471,616 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,616 software developers and data experts.

ToolTip in VS2005

I have a winform with 20 text boxes; some text boxes have default values and
some are blank. I have the following code to display ToolTip for each of the
TextBox controls:

System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();

foreach (Control ctrl in this.Controls)
{
if (ctrl is TextBox)
{

ToolTip1.SetToolTip(ctrl, ctrl.Text);
}
}

When I change data or add data to a blank textbox control; the ToolTip will
not display updated information.
How do I resolve this issue?
Sep 10 '08 #1
2 2583
=?Utf-8?B?Unlhbg==?= <Ry**@discussions.microsoft.comwrote in
news:6C**********************************@microsof t.com:
I have a winform with 20 text boxes; some text boxes have default
values and some are blank. I have the following code to display
ToolTip for each of the TextBox controls:

System.Windows.Forms.ToolTip ToolTip1 = new
System.Windows.Forms.ToolTip();

foreach (Control ctrl in this.Controls)
{
if (ctrl is TextBox)
{

ToolTip1.SetToolTip(ctrl, ctrl.Text);
}
}

When I change data or add data to a blank textbox control; the ToolTip
will not display updated information.
How do I resolve this issue?
Without asking the obvious question of "Why set the tooltip text to the
control text" you probably need to capture the event when the user is
changing the text in the box... The code above only sets the tooltip to
what it is at the time the code runs - it doesn't mean to make the tooltip
whatever is in the control when the tooltip appears. Try capturing the
keypressed event or something like that, and then re-set the tooltip. You
might also need to append the character being typed?

-mdb
Sep 10 '08 #2
I do not want to set the ToolTip for each individual TextBox control
manually. I am looking for a more dynamic way to accomplish the same using a
similiar code that I provided earlier.
Basically, the moment form becomes Dirty,then execute the method that
iterate through each of the TextBox controls and re-set the ToolTip basesd on
its current value.

Any other ideas?

"Michael Bray" wrote:
=?Utf-8?B?Unlhbg==?= <Ry**@discussions.microsoft.comwrote in
news:6C**********************************@microsof t.com:
I have a winform with 20 text boxes; some text boxes have default
values and some are blank. I have the following code to display
ToolTip for each of the TextBox controls:

System.Windows.Forms.ToolTip ToolTip1 = new
System.Windows.Forms.ToolTip();

foreach (Control ctrl in this.Controls)
{
if (ctrl is TextBox)
{

ToolTip1.SetToolTip(ctrl, ctrl.Text);
}
}

When I change data or add data to a blank textbox control; the ToolTip
will not display updated information.
How do I resolve this issue?

Without asking the obvious question of "Why set the tooltip text to the
control text" you probably need to capture the event when the user is
changing the text in the box... The code above only sets the tooltip to
what it is at the time the code runs - it doesn't mean to make the tooltip
whatever is in the control when the tooltip appears. Try capturing the
keypressed event or something like that, and then re-set the tooltip. You
might also need to append the character being typed?

-mdb
Sep 10 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Yves Royer | last post: by
reply views Thread by Yves Royer | last post: by
5 posts views Thread by =?Utf-8?B?cGV0ZTE5Njk=?= | last post: by
3 posts views Thread by Rainer Queck | last post: by
1 post views Thread by =?Utf-8?B?Q2hyaXMgRGF2b2xp?= | last post: by
7 posts views Thread by =?Utf-8?B?U2hhcm9u?= | last post: by
1 post views Thread by =?Utf-8?B?Unlhbg==?= | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.