J
Johnny Jörgensen
Can anybody help me with this problem, please:
I've got a class
public MyClass
{
private string m_TextValue = "";
public void SetValues()
{
m_TextValue = "Test";
}
public string TextValue
{
get { return m_TextValue; }
set { m_TextValue = value; }
}
}
and in a form I instatiate my class
private MyClass MyClassInstance = new MyClass();
I bind the TextValue property of MyClassInstance to a Textbox' Text field in
the Form_Load event:
textBox1.DataBindings.Add("Text", MyClassInstance, "TextValue");
(I can also do this using the DataBindings field in the Property editor, but
that doesn't change anything)
I would expect textbox1 to show "" now (which it does).
Then I call:
MyClassInstance.SetValues();
Then I would expect textBox1 to show "Test" (which it DOESN'T!)
But if I enter text into textBox1, it is correctly transferred to the
MyClassInstance.TextValue property, so I know the databinding works. What I
don't understand is why the SetValues method changes doesn't reflect in the
bound control's property.
What am I missing?
TIA,
Johnny Jörgensen
I've got a class
public MyClass
{
private string m_TextValue = "";
public void SetValues()
{
m_TextValue = "Test";
}
public string TextValue
{
get { return m_TextValue; }
set { m_TextValue = value; }
}
}
and in a form I instatiate my class
private MyClass MyClassInstance = new MyClass();
I bind the TextValue property of MyClassInstance to a Textbox' Text field in
the Form_Load event:
textBox1.DataBindings.Add("Text", MyClassInstance, "TextValue");
(I can also do this using the DataBindings field in the Property editor, but
that doesn't change anything)
I would expect textbox1 to show "" now (which it does).
Then I call:
MyClassInstance.SetValues();
Then I would expect textBox1 to show "Test" (which it DOESN'T!)
But if I enter text into textBox1, it is correctly transferred to the
MyClassInstance.TextValue property, so I know the databinding works. What I
don't understand is why the SetValues method changes doesn't reflect in the
bound control's property.
What am I missing?
TIA,
Johnny Jörgensen