Click here to Skip to main content
15,917,565 members
Home / Discussions / C#
   

C#

 
QuestionChoosing and setting a control's property programatically Pin
Dewald14-Nov-07 21:59
Dewald14-Nov-07 21:59 
AnswerRe: Choosing and setting a control's property programatically Pin
Martin#14-Nov-07 22:07
Martin#14-Nov-07 22:07 
GeneralRe: Choosing and setting a control's property programatically Pin
Dewald15-Nov-07 0:00
Dewald15-Nov-07 0:00 
GeneralRe: Choosing and setting a control's property programatically Pin
Martin#15-Nov-07 0:04
Martin#15-Nov-07 0:04 
GeneralRe: Choosing and setting a control's property programatically Pin
Dewald15-Nov-07 1:28
Dewald15-Nov-07 1:28 
GeneralRe: Choosing and setting a control's property programatically Pin
Martin#15-Nov-07 1:49
Martin#15-Nov-07 1:49 
GeneralRe: Choosing and setting a control's property programatically Pin
Dewald15-Nov-07 2:53
Dewald15-Nov-07 2:53 
GeneralRe: Choosing and setting a control's property programatically Pin
Martin#15-Nov-07 3:09
Martin#15-Nov-07 3:09 
Hello Again,

Dewald wrote:
I hope I'm not getting too tedious with my questions but I appreciate your help.

No way!
This is a very interesting discusion, thanks for that!

Now to your problem:
Reflection in combination with delegates is something I have never done.
So I can only give you a maybe dirty solution (but maybe also the only one possible).

I would cast to the object to the appropriate type and then do your stuff.
...
Button actButton = ctrlInstance as Button;
if(actButton!=null)
{
    actButton.Click+=...
}

If you have more than one type to validate for some other action with Label, CheckBox, ...
if(ctrlInstance is Button)
{
    Button actButton = ctrlInstance as Button;
    actButton.Click+=...
}
else if(ctrlInstance is Label)
{
    Label actLabel = ctrlInstance as Label;
}
...

Hope that someone will come up with a cleaner solution,
but maybe it fitts your needs.

All the best,

Martin

GeneralRe: Choosing and setting a control's property programatically Pin
Dewald15-Nov-07 4:51
Dewald15-Nov-07 4:51 
GeneralRe: Choosing and setting a control's property programatically Pin
Martin#15-Nov-07 20:35
Martin#15-Nov-07 20:35 
GeneralRe: Choosing and setting a control's property programatically Pin
Dewald15-Nov-07 21:09
Dewald15-Nov-07 21:09 
GeneralRe: Choosing and setting a control's property programatically Pin
Martin#15-Nov-07 21:11
Martin#15-Nov-07 21:11 
QuestionExecution Problem Pin
DeepOceans14-Nov-07 21:59
DeepOceans14-Nov-07 21:59 
AnswerRe: Execution Problem Pin
Adeel Chaudhry14-Nov-07 22:10
Adeel Chaudhry14-Nov-07 22:10 
GeneralRe: Execution Problem Pin
DeepOceans14-Nov-07 23:29
DeepOceans14-Nov-07 23:29 
GeneralRe: Execution Problem Pin
Adeel Chaudhry14-Nov-07 23:35
Adeel Chaudhry14-Nov-07 23:35 
GeneralRe: Execution Problem Pin
Luc Pattyn15-Nov-07 1:49
sitebuilderLuc Pattyn15-Nov-07 1:49 
GeneralRe: Execution Problem Pin
DeepOceans15-Nov-07 20:44
DeepOceans15-Nov-07 20:44 
GeneralRe: Execution Problem Pin
Luc Pattyn16-Nov-07 2:37
sitebuilderLuc Pattyn16-Nov-07 2:37 
GeneralRe: Execution Problem Pin
DeepOceans19-Nov-07 1:01
DeepOceans19-Nov-07 1:01 
GeneralRe: Execution Problem Pin
Luc Pattyn19-Nov-07 1:21
sitebuilderLuc Pattyn19-Nov-07 1:21 
QuestionChristian Graus can you help me with this? Pin
MumbleB14-Nov-07 21:40
MumbleB14-Nov-07 21:40 
AnswerRe: Christian Graus can you help me with this? Pin
Christian Graus14-Nov-07 21:53
protectorChristian Graus14-Nov-07 21:53 
GeneralRe: Christian Graus can you help me with this? Pin
MumbleB14-Nov-07 22:01
MumbleB14-Nov-07 22:01 
GeneralRe: Christian Graus can you help me with this? Pin
Christian Graus14-Nov-07 22:12
protectorChristian Graus14-Nov-07 22:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.