ToolTip in VS2005

R

Ryan

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?
 
M

Michael Bray

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
 
R

Ryan

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?
 

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