c# - Dynamically binding data contained within an object to labels in a windows form -


i have following data , objects in program.

a dynamicobjectcontainer contains following objects.

  1. measurementparameters : datacontainer (datacontainer base class)

this measurementparameters object has many public properties, names know only during runtime. have set internal wiring in datacontainer base class such that, can access values of properties contained in measurementparameters class using easy use interface.

ex : have property in measurementparameters named "pumpspeed" (type string). can access value of property using function.

measurementparameters.getstringvalue("pumpspeed"); 

i have achieved creating lists of delegates internally in datacontainer object using reflection during construction of object. (this 1 time thing.)

so far good.

now stuck @ point want display these values within measurementparameters in windows form.

since know property names @ runtime, have provide user method map property names (defined him in script file) fixed labels within form. user saves mapping data table in following format.

entry : "pumpspeed" "label22" 

i want fast , efficient method fetch mapping database, fetch required data measuremetparameters object , display in windows form.

note : if 1 time operation, have many solutions. problem 2 fold.

  1. there huge number of properties in measurementparameters (at around 200)
  2. the measurementparameters object contains functions update it's properties continuously. windows form has call functions update measurementparameters object data, fetch data , display in correct labels.

also, should happen in cycles of around 2 -3 times second. (ideally)

can me in architecting solution this?? general object structure , relationship advice helpful me.

i can post code using if required.

not seeing huge problem here

so have table objectid, propertyname, controlname

on opening form / selecting object, query them out build dictionary keyed propertyname value of label (looked name of teh control query myform.controls.findbyname(somename). add onpropertychangedevent class throws name of property in event args add handler on form

mappings[e.propertyname].text = object[e.propertyname].getstringvalue; 

might have twidlle deal display controls aren't labels, or panels on form, should batter away.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -