I read some about DataBinding, mostly complex things like SQL or any XAML and stuff. All I want my program to do is that if the "value" of a variable changes, just write it in a text box or shortcut. (using WindowsForms)
So far I have had:
namespace DataBinding_Test { public partial class Form1 : Form { BindingSource bs = new BindingSource(); Class1 test = new Class1(); public Form1() { InitializeComponent(); test.name = "Hello"; bs.DataSource = test; label1.DataBindings.Add(new Binding("Text", bs, "name", false, DataSourceUpdateMode.OnPropertyChanged)); } private void button1_Click(object sender, EventArgs e) { test.name = textBox1.Text; } } }
Class1 simply has a public property name. When launched, lable1 will show my "Hello" line. Then, when you click the button, the name of the property changes. When debugging, I saw that the actual DataSource from "bs" contains the new property value, but the label will not show anything ...
Is there any real way to do this?
Rear panel: The RS232 data sensor will be periodically polled. If the value of one sensor changes, I want to show it in a shortcut or text box. Now the backroundthreaded timer will need calls and materials to access the GUI stream; thought it would be easier with data binding, but didn't seem to look: P
Thank you all, great site, great job! :)
source share