You are here:

C#/dinamic text for a tooltip

Advertisement


Question
Hi Nick
I have this need:
In Form1 obj TextBox1 is editable and I need a tooltip that shows the text that can 'change from time to time in textBox1 (TextBox1.Text)
How do I set the parameter "string" in the command SetToolTip (this.mytextbox, "string");

Thanks in advance

Hello Carlo

Answer

Tool Tip Text Changes
I'm not quite sure what you're asking, but I'll take a guess and show you what I've got. I created a Windows Forms application with three controls on it: a button (button1), a tool tip (toolTip1), and a timer (timer1). I set the timer's interval to 1 second. I also created a class-level variable called "amount" and set it initially to zero. In the "Tick" event for the timer, I incremented "amount" and then set the tool tip on the button based on that amount:

// C# code:
this.toolTip1.SetToolTip(this.button1, "amount = " + amount.ToString());

So, every second ("from time to time") the tool tip text changes. That button could have just as easily been a text box, as you have described.

Hope that helps!

Nick

Expertise

I can answer questions regarding C#, C++, SQL, Visual Basic, .Net Framework 2.0, general programming technique, and general algorithm development. My current area of focus is C#.

Experience

C++/VB programmer since 10th grade. I used to love video game development (still do, just don't do it anymore). Have real world experience in 4 companies for a total of about 4 years non-academic experience.

Organizations
Innotrac (we deal with order fulfillment)

Publications
CodeProject.com

Education/Credentials
BS in Computer Science with minor in Entertainment Technology.

Awards and Honors
"The Next Bill Gates" gag award :-). College: Summa Cum Laude.

©2012 About.com, a part of The New York Times Company. All rights reserved.