Lucas
Lucas

Reputation: 27

set tooltip text to textbox

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

Upvotes: 2

Views: 1593

Answers (2)

IndieGameDev
IndieGameDev

Reputation: 2974

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

Upvotes: 1

Lucas
Lucas

Reputation: 27

Picture of textbox property window.

property window

breakpoint etc

Upvotes: 0

Related Questions