ChubbyArse Posted August 22, 2003 Posted August 22, 2003 Hi, I'm writing a generic class to support databinding in a form. I have a formfields collection which collects formfield objects which have each fieldname, controlname, mandatory, defaultvalue and originalvalue properties. The problem i have is that when I want to check the value in the control, this could be stored in one of a few different properties (at the moment - text, checked, value, selectedvalue). I would like to have a BindingProperty on the formfield object that states which property is the binding property. This would be a string ("text", "checked", "value", "selectedvalue", this would supply the binding.add method when I loop through and bind the controls). But how do I get the value of the property when the propertyname is stored as a string?? Can you reference a controls property some other flashier way?? Am I barking up the wrong tree, or has someone already does this somewhere ......? (don't care if they have though, this is great learning curve!!!) Cheers Alex Stevens Gloucester, England Quote
ChubbyArse Posted August 22, 2003 Author Posted August 22, 2003 Solved: Managed to solve this without using relflection, using the callbyname function. It allows you to get/set a property of an object: CallByName(txtForename, "Text", CallType.Get) CallByName(txtForename, "Text", CallType.Set, "Alex") Alex Quote
*Experts* Nerseus Posted August 22, 2003 *Experts* Posted August 22, 2003 Normally you don't care about the value of the control. The DataSet (or whatever you're binding to) is usually the "master" of the data and is what you care about. Normally you only care about the value in the control if you're doing some kind of pre-validation before moving the data into the datasource. But, you can usually handle that through the Format/Parse events (Parse is the one to get the data from the control and convert it to whatever is needed in the datasource). But, I'm glad you found a solution :) -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.