Databinding proves to be very useful in some cases, but often turns out to be a maintenance nightmare. Since it requires strings with the property names to be passed as parameters of the Binding object. When the class, where a textbox is binded to, changes over time, so do property names. But since these property names are passed around as a string, they do not raise compile errors, causing unexpected behaviour of the application.
Here’s how you can make these bindings strongly typed, causing compilation errors if the property name of a class would change. Imagine we would like to bind a textbox to the Name property of the Person class, here’s the function that is going to help us. This function has a lambda expression returning a string and receiving a Person as parameter.
public string GetPropertyName(Expression<Func<Person, string>> propertySelector) { MemberExpression memberExpression = propertySelector.Body as MemberExpression; MemberInfo propertyInfo = memberExpression.Member; return propertyInfo.Name; }
The original binding code would like this, notice the “Name” string.
m_TextEditPerson.DataBindings.Add(new Binding("Text", m_Person, "Name"));
Here’s the new binding statement.
m_TextEditPerson.DataBindings.Add(new Binding("Text", m_Person, GetPropertyName(x => x.Name)));
Tags: databinding

allergic reaction to topical miconazole…
Buy_generic meds…
social interaction anxiety…
Buy_without prescription…
at home diet programs…
Buy_generic pills…
psychotic depression and philadelphia…
Buy_generic meds…
shampoo for people with dog allergies…
Buy_now…
menopause thyroid cancer…
Buy_without prescription…
how can i lower my cholesterol…
Buy_generic drugs…
boniva and bone thinning and breaks…
Buy_now it…
foods with triglycerides in them…
Buy_generic drugs…
flat warts and probiotics…
Buy_generic drugs…
medicare drugs covered…
Buy_generic meds…
state of arizona ontiveros drug…
Buy_now it…
lexapro versus prozac differences…
Buy_without prescription…
sample ncp for diabetes…
Buy_without prescription…
what year was advil introduced…
Buy_now it…
Download@pop.Rock” rel=”nofollow”>.…
Buy rock US Charts…
children@prozac.buy” rel=”nofollow”>……
Buywithout prescription…
hairstyles…
Its like you read my mind! You appear to know so much about this, like you wrote the book in it or something. I think that you could do with a few pics to drive the message home a bit, but other than that, this is wonderful blog. A great read. I’ll ce…