Expression has been evaluated and has no value - string binding

N

Nick Valeontis

code:
---------------- ---------------- ---------------- --------------------------------
----------------
namespace TestApp {
public partial class Form1 : Form {

private object s = "1";

public Form1() {
InitializeComponent();
Binding b = new Binding("Text", s, null, false,
DataSourceUpdateMode.OnPropertyChanged);
textBox2.DataBindings.Add(b);
}

private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
MessageBox.Show(" s = "+ s);
}

private void button1_Click_1(object sender, EventArgs e) {
//textBox2.DataBindings["Text"].ReadValue();
textBox2.DataBindings["Text"].WriteValue();
}

}
}
---------------- -------------------------------- --------------------------------
-------------------------------- -------------------------------- ----------------

problem:

-> textBox2.DataBindings["Text"].ReadValue();

works okay, value "1" is copied to the textbox.

However, if I change the value of the textbox to "5" and then try
textBox2.DataBindings["Text"].WriteValue(); nothing happens. When exiting
the form, s is still "1".

Have I misunderstood something?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top