forms - How to bind control's properties to variables in C#? -


I have lots of textboxes and there are lots of threads in my program that need to read the contents of those text boxes ( Settings). Since I can not see the control from other threads, I decided to create a special class which will keep all the settings, and if the user changes something, then the control will invite the antitech event and change the corresponding value in the class. But if I use that approach, then many similar handlers will be connected in this way

  private zeros txtCrap1_TextChanged (Object Sender, EventArgs e) {Settings.Crap1 = txtCrap1.Text; }  

What I have to do is do something like

  Private Zero SetupControlBindings () {AddBinding (txtCrap1, Settings.Crap1); AddBinding (txtCrap2, Settings.Crap2); } Private Zero AddBinding (Object Control, Object Value) {// Add Entry to Any Kind of Dictionary} Private Zero UpdateValue (Object Sender, EventArgs E) {If (Sender Text Box) {// Find it in dictionary and find the appropriate value Change}}  

But I can not find any signal in C # How to do any idea?

PS I can not use reflection because my code will be obscured after compiling

upd: My program is actually a bit more complicated. I have not only text boxes, but checkboxes, numeric backups, etc. I also want to have my settings class hold some additional objects like lists.

The way I normally do something like this, using data binding Used to be.

  txtCrap1.DataBindings.Add ("Text", Settings, "Crap1"); ChkCrap2.Datbindings.ad ("check", settings, "scrap 2");  

The problem is definitely ambiguous but when you can leave things like whole classes, methods or attributes, then you can exclude the properties of the settings class from ambiguity and Then you may be able to use normal data binding. Depending on how you will remove the asset, depending on the structure you use.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -