When NOT to Reflection

  • Thread starter Thread starter jack
  • Start date Start date
J

jack

Hello,

I found a reply by Peter Huang to a previous post quite valuable with regard
to referencing controls on a form by name using reflection. It made me
wonder when I would not use Reflection for this task (or any other similar
task). So, I thought I'd ask the question ... when is Reflection not an
appropriate solution (especially with regard to getting controls by name)?

Thanks!
Jack
 
Jack,
So, I thought I'd ask the question ... when is Reflection not an
appropriate solution (especially with regard to getting controls by name)?

For me has this a simple answer *forever* when you don't need it. It is just
late binding.

In addition I don't see any problem to solve with it which cannot be done
better without it, with the exception maybe when you are building your own
compiler or something like that.

Cor
 
jack said:
I found a reply by Peter Huang to a previous post quite valuable with
regard to referencing controls on a form by name using reflection. It made
me wonder when I would not use Reflection for this task (or any other
similar task). So, I thought I'd ask the question ... when is Reflection
not an appropriate solution (especially with regard to getting controls by
name)?

Reflection will only work in this case when there is a variable referencing
the control. It won't work for controls added at runtime which do not
belong to a member variable.
 
Thanks for the feedback. Previously, I loaded the controls into a hash table
when the form loaded. I guess your recommendation is to go back to that
method?

Jack
 
Jack,
Thanks for the feedback. Previously, I loaded the controls into a hash
table when the form loaded. I guess your recommendation is to go back to
that method?

How did you know that, I had the idea to write that already in my first
message.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top