Design time support for components an UserControls

  • Thread starter Thread starter Efy
  • Start date Start date
E

Efy

Hello all,

Design time support for components an UserControls

I need some guidance or direction to the following: I need to create a
user control that includes some public properties let's say a simple
Button, When the user control will be dragged in design time to a form
[I am talking now about Windows Form] I would like the developer to
still be able to change the location of the Button on the user
control, in design time. I know that he can change the location thru
the property window but it's not comfortable, I would like to allow
him to do it by dragging the member control.

Is this possible at all???

Thank you so much!
Efy
 
I need some guidance or direction to the following: I need to create a
user control that includes some public properties let's say a simple
Button, When the user control will be dragged in design time to a form
[I am talking now about Windows Form] I would like the developer to
still be able to change the location of the Button on the user
control, in design time. I know that he can change the location thru
the property window but it's not comfortable, I would like to allow
him to do it by dragging the member control.

Is this possible at all???

Yes. You need to:

1) Create a custom designer for your control (a class inherited from
ControlDesigner). Associate it with your control class using
DesignerAttribute.
2) Override ControlDesigner.Initialize(), and call
ControlDesigner.EnableDesignMode() for all child controls that you
want to be exposd.
 
I need some guidance or direction to the following: I need to create a
usercontrol that includes some public properties let's say a simple> Button, When the user control will be dragged in design time to a form
[I am talking now about Windows Form] I would like the developer to
still be able to change the location of the Button on the user
control, in design time. I know that he can change the location thru
the property window but it's not comfortable, I would like to allow
him to do it by dragging the member control.
Is this possible at all???

Yes. You need to:

1) Create a custom designer for your control (a class inherited from
ControlDesigner). Associate it with your control class using
DesignerAttribute.
2) Override ControlDesigner.Initialize(), and call
ControlDesigner.EnableDesignMode() for all child controls that you
want to be exposd.

Thank you very much! You a very kind person, you have no idea how much
you helped me,I have been searching for that for along time before I
have posted the question and I did not see any so simple and clear
answer, that got me right there.
Now, I see that the designer serializes the button and I can even take
it out of the bounds of the control, do you have an idea on how to
prevent this behavior?


Thanks again'
Efy
 
Thank you very much! You a very kind person, you have no idea how much
you helped me,I have been searching for that for along time before I
have posted the question and I did not see any so simple and clear
answer, that got me right there.
Now, I see that the designer serializes the button and I can even take
it out of the bounds of the control, do you have an idea on how to
prevent this behavior?

If by "designer serializing the button" you mean that it writes code
to set its properties, then surely it's what you want it to do (since
you'd want it to remember at run-time where the user has dragged it at
compile-time)?

I'm not so sure about dragging out. I don't recall seeing that
behavior when I tried that myself, but it was a while ago, and my
memory is hazy. Still, googling around on the new keywords you have
(such as EnableDesignMode) will probably be much more productive now
then the first attempt, so you may find something useful on this. If
so, you might want to share your findings here.
 
Back
Top