Re: set a property of inherited class from base class
From: hOSAM (hosam.shahin$$gmail.com)
Date: 09/22/04
- Next message: andrew lowe: "Mixed mode COM issues"
- Previous message: PhilN: "RE: Parsing Special Character in text file"
- In reply to: TS: "set a property of inherited class from base class"
- Next in thread: TS: "Re: set a property of inherited class from base class"
- Reply: TS: "Re: set a property of inherited class from base class"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 23 Sep 2004 02:57:14 +0300
Try this;
this.GetType().GetProperty("panel1").SetValue(this, 44, null);
Where the property name is "panel1", and the value is 44.
Anyways, I don't think this is good. What you are trying to do aggressively
violates encapsulation. In100% of cases there are better ways to do things
like this using OOP paradigms.
For example, you can have that property virtual/abstract on the base class,
so that the inherters implement it, and you can directly modify it without
the reflection overhead.
"TS" <manofsteele@311.com> wrote in message
news:##wb5kPoEHA.3252@TK2MSFTNGP11.phx.gbl...
> I am trying to get set a property of a control on the inherited class from
> base class. I imagine i have to use reflection, so could someone give me
the
> code to do it?
>
> something like this?
> this.GetType().GetMember("panel1").SetValue(xx).Left = 44;
>
>
>
>
- Next message: andrew lowe: "Mixed mode COM issues"
- Previous message: PhilN: "RE: Parsing Special Character in text file"
- In reply to: TS: "set a property of inherited class from base class"
- Next in thread: TS: "Re: set a property of inherited class from base class"
- Reply: TS: "Re: set a property of inherited class from base class"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|