Databinding Textbox to Form.Text (title)
- by MysticEarth
I'm trying to bind a Textbox.Text to Form.Text (which sets the title of the form).
The binding itself works. But, the title isn't updated until I move the entire form.
How can I achieve Form.Text being updated without moving the form? I'd like Form.Text being updated directly when I type something in the Textbox.
Edit; I set the title of the Form in a TextChanged event which is fired by a ToolStripTextbox:
public partial class ProjectForm : Form
{
public ProjectForm()
{
// my code contains all sorts of code here,
// but nothing that has something to do with the text.
}
}
private void projectName_TextChanged_1(object sender, EventArgs e)
{
this.Text = projectName.TextBox.Text;
}
And the Databinding version:
public partial class ProjectForm : Form
{
public ProjectForm()
{
this.projectName.TextBox.DataBindings.Add("Text", this, "Text", true, DataSourceUpdateMode.OnValidation);
}
}
Edit 2: I see I forgot to mention something. Don't know if it adds anything, but my apllication is a MDI application. The part of the title that changes is:
ApplicationName [THIS CHANGES, BUT ONLY AFTER MOVING/RESIZING]