c# - Simple Windows Forms data binding -


let's have string property in form (and form not implement inotifypropertychanged). i've created bindingsource , set datasource form. bind textbox string property on form (indirectly, using bindingsource).

question 1: when change value in textbox @ runtime, why don't hit breakpoint in setter of string property? thought binding control string property allow updates in direction (gui -> member data) occur automatically

question 2: how can trigger updates in other direction (member data -> gui) occur when other gui changes string property? don't want implement inotifypropertychanged interface , add notifypropertychanged setter. thought using bindingsource's resetbindings @ least trigger manually

public partial class form1 : form {     private string m_blah;     public string blah     {                  {             return m_blah;         }         set         {             m_blah = value;         }     }      public form1()     {         initializecomponent();         textbox1.databindings.add(new binding("text", bindingsource1, "blah",true,datasourceupdatemode.onvalidation));     }      private void button1_click(object sender, eventargs e)     {         blah = "clicked!";         this.bindingsource1.resetbindings(false); //expecting gui update , "clicked!"     } } 

this.bindingsource1.datasource = this; 

i think forget assign data source.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -