Dynamic resolution

  • Thread starter Thread starter AA2e72E
  • Start date Start date
A

AA2e72E

If I have an expression such as:

this.supportEmailIDBindingSource.EndEdit();

which works but the expression is in a loop which causes the child object of
'this' to change.

If I assign

bindingSource="supportEmailIDBindingSource"

How can I resolve the original expression?

I've tried

(this.(bindingSource)).EndEdit();

and several variations of this expression without success. Is there a way
that will permit me to resolve the 2nd level i.e. allow dynamic substitution
of bindingSource?

Thanks.
 
AA2e72E said:
If I have an expression such as:

this.supportEmailIDBindingSource.EndEdit();

which works but the expression is in a loop which causes the child object of
'this' to change.

If I assign

bindingSource="supportEmailIDBindingSource"

How can I resolve the original expression?

You have to do this by hand. For example:

string bindingSource = "supportEmailIDBindingSource";
BindingSource bs;
... loop ...
{
switch( bindingSource )
{
case "supportEmailIDBBindingSource":
bs = this.supportEmailIDBindingsource;
break;
case "someOtherBindingSource":
bs = this.someOtherBindingSource;
break;
...
}
bs.EndEdit();
...
bs = "someOtherBindingSource";
}
 
Back
Top