2

Picture:

very nice picture

Tooltip

Breakpoint

I want my tooltip to show the text that is set in a textbox, how can I do this exactly? Yes I know the Tooltip property but textbox.Text does not work, I just want to show textbox text in tooltip (dynamic).

Thanks for your help

IndieGameDev
  • 2,905
  • 3
  • 16
  • 29
Lucas
  • 27
  • 5

2 Answers2

1

if you want to change the Tooltip each time the TextBoxText has changed you can put the SetToolTip() Function into the OnTextChanged() Callback.

ToolTip toolTip1 = new ToolTip();

public Form1() {
    InitializeComponent();
    toolTip1.ShowAlways = true;
    toolTip1.ToolTipTitle = "TextBox Text";
    toolTip1.SetToolTip(textBox1, textBox1.Text);
}

private void OnTextChanged(object sender, EventArgs e) {
    toolTip1.SetToolTip(textBox1, textBox1.Text);
}

To add the TextChanged Event you need to open the TextBoxs Property page, click on the Thunderbolt and add the Function Name to the TextChanged Row.

TextChanged

IndieGameDev
  • 2,905
  • 3
  • 16
  • 29
  • no look i just want a tooltip when i hover over the textbox, tooltip text has to be the same as textbox's – Lucas Oct 02 '20 at 12:49
  • i tried what you suggested but it\s not showing, i added a new tooltip to designer too – Lucas Oct 02 '20 at 12:50
  • ok.. now how can i show it. toolTip1.Show() or toolTip.ShowAlways = true ? – Lucas Oct 02 '20 at 13:00
  • Error The name 'e' does not exist in the current context – Lucas Oct 02 '20 at 13:07
  • what did you fix? still not working for me btw i use TextChanged, i dont know if theres a difference dont think so – Lucas Oct 02 '20 at 13:19
  • nah that's just the name that should be fine, I changed the `OnTextChanged` Function – IndieGameDev Oct 02 '20 at 13:21
  • oh yes i see i use the newest function now. but still same error: 'e' does not exist in current context does it work for you? – Lucas Oct 02 '20 at 13:25
  • its kinda like this question https://stackoverflow.com/questions/38244139/textbox-string-as-tooltip-on-hover but it's in vb code..... :/ – Lucas Oct 02 '20 at 13:27
  • Nope unfortunately not working. did you assign the tooltip to the textbox or something? wait i will add another picture – Lucas Oct 02 '20 at 13:39
0

Picture of textbox property window.

property window

breakpoint etc

Lucas
  • 27
  • 5