If I understand your question, you are updating the TextBox.Text property on a bound TextBox.
Don't do this !
If you need to update the text in that TextBox, update the underlying DataSource
Cheers
Question
I have a TextBox
with a data binding, which I later update the text on via the combobox_selectedindexchanged()
event of ComboBox
.
My problem is that the data gets changed on this combobox_selectedindexchanged()
event but when i click on the TextBox
data gets disappeared.
Solution
If I understand your question, you are updating the TextBox.Text property on a bound TextBox.
Don't do this !
If you need to update the text in that TextBox, update the underlying DataSource
Cheers
OTHER TIPS
I created a project do whatever as you mentioned above. The TextBox
's Text changed into "Foo" after comboBox_SelectedIndexChanged
event, then when I click on the TextBox
, it is still there. Here's my code.
private Foo _foo;
public Form1()
{
InitializeComponent();
_foo = new Foo();
txtName.DataBindings.Add("Text", _foo, "Name");
}
private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
txtName.Text = "Foo";
}
Does you change the TextBox
's Text elsewhere? Maybe you should post your code here, so we can see what the matter is.