By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,644 Members | 2,082 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,644 IT Pros & Developers. It's quick & easy.

How to make custom control act like container for other controls

P: n/a
Hello

i have made a custom control. i have placed a panel on it. I want this
panel to behave just like the normal panel. The problem i was having is
that the panel on my custom control doesnt accept other controls. The
control i drag drop on it becomes the child of my custom control's
parent form and not the child of my custom control. Then i added this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line does). Now
when i drag drop a control (say text box) onto the panel of my custom
control, the newly added control goes behind the custom control. It
becomes the child of my Custom control but i am unable to bring it to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that accepts other
control on design time (through drag drop) and behaves like ordinary
user control.

Regards
Rizwan

Jan 4 '07 #1
Share this Question
Share on Google+
15 Replies


P: n/a
Hi Rizwan,

To support drag & drap in the designer for your custom control you can
inherit from ContainerControl instead of Control or use the
DesignerAttribute as you have illustrated.

However, you won't be able to drag & drop controls into a Panel that is
within your control. Drag & drop support doesn't go that "deep".

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hello

i have made a custom control. i have placed a panel on it. I want this
panel to behave just like the normal panel. The problem i was having is
that the panel on my custom control doesnt accept other controls. The
control i drag drop on it becomes the child of my custom control's
parent form and not the child of my custom control. Then i added this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line does). Now
when i drag drop a control (say text box) onto the panel of my custom
control, the newly added control goes behind the custom control. It
becomes the child of my Custom control but i am unable to bring it to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that accepts other
control on design time (through drag drop) and behaves like ordinary
user control.

Regards
Rizwan

Jan 5 '07 #2

P: n/a
Hello

i have now removed panel from my custom control. The control added by
drag drop is now becoming the child of my custom control but When i
compile the application after dropping a control say text box on my
custom control, the controls present on the template of custom control
disappear.
i have two controls defined in the template, a checkbox and an image.
There are two picture boxes as the property of the custom control too.
The property picture boxes (which i specify at the design time) remains
intact while those (check box and picture box) which are the part of
template disappear.

I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong now?

Regards
//Rizwan
Dave Sexton wrote:
Hi Rizwan,

To support drag & drap in the designer for your custom control you can
inherit from ContainerControl instead of Control or use the
DesignerAttribute as you have illustrated.

However, you won't be able to drag & drop controls into a Panel that is
within your control. Drag & drop support doesn't go that "deep".

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hello

i have made a custom control. i have placed a panel on it. I want this
panel to behave just like the normal panel. The problem i was having is
that the panel on my custom control doesnt accept other controls. The
control i drag drop on it becomes the child of my custom control's
parent form and not the child of my custom control. Then i added this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line does). Now
when i drag drop a control (say text box) onto the panel of my custom
control, the newly added control goes behind the custom control. It
becomes the child of my Custom control but i am unable to bring it to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that accepts other
control on design time (through drag drop) and behaves like ordinary
user control.

Regards
Rizwan
Jan 5 '07 #3

P: n/a
Hi Rizwan,

I don't really understand the problem.

By "template" do you mean your custom control in its default state when it's
first added to a Form?

Are the disappearing controls disappearing in the designer, at runtime or
both?

Are you adding the disappearing controls to your custom control in its
constructor or upon some event such as Load? Are they even being added by
the custom control itself?

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
Hello

i have now removed panel from my custom control. The control added by
drag drop is now becoming the child of my custom control but When i
compile the application after dropping a control say text box on my
custom control, the controls present on the template of custom control
disappear.
i have two controls defined in the template, a checkbox and an image.
There are two picture boxes as the property of the custom control too.
The property picture boxes (which i specify at the design time) remains
intact while those (check box and picture box) which are the part of
template disappear.

I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong now?

Regards
//Rizwan
Dave Sexton wrote:
>Hi Rizwan,

To support drag & drap in the designer for your custom control you can
inherit from ContainerControl instead of Control or use the
DesignerAttribute as you have illustrated.

However, you won't be able to drag & drop controls into a Panel that is
within your control. Drag & drop support doesn't go that "deep".

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googleg roups.com...
Hello

i have made a custom control. i have placed a panel on it. I want this
panel to behave just like the normal panel. The problem i was having is
that the panel on my custom control doesnt accept other controls. The
control i drag drop on it becomes the child of my custom control's
parent form and not the child of my custom control. Then i added this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line does). Now
when i drag drop a control (say text box) onto the panel of my custom
control, the newly added control goes behind the custom control. It
becomes the child of my Custom control but i am unable to bring it to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that accepts other
control on design time (through drag drop) and behaves like ordinary
user control.

Regards
Rizwan

Jan 5 '07 #4

P: n/a
Hi Dave

lot of thanks for replying.

by template control i mean the controls which are added in its default
state, for example , the maximize minimze image, It is there in the
default state, and user can not change it in design time.

Disappearing controls: The controls (only default controls) disappear
when i compile the application. When i add my custom control to a form,
every thing is fine. i compiel the code, works fine. when i add
control from toolbar by drag drop, everything works fine. But as soon
as i compile the application (after adding control from toolbar), the
controls (only default controls) disappear. And ofcourse when i run the
application they are not visible too.

i have two default controls on custom control, one is check box and
other is picture box. I add these controls during the desiging of the
custom control (not the design time of form). I set the picture for
picture control and check the checkbox in the constructor of the custom
control. After building the code, my custom control is ready for use
with two default controls on it. Please note that there is also a group
box used as line seperator (it is also a default control). but this
group box doesnt disappear. on compile time

i hope the situation is clear now :)

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

I don't really understand the problem.

By "template" do you mean your custom control in its default state when it's
first added to a Form?

Are the disappearing controls disappearing in the designer, at runtime or
both?

Are you adding the disappearing controls to your custom control in its
constructor or upon some event such as Load? Are they even being added by
the custom control itself?

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
Hello

i have now removed panel from my custom control. The control added by
drag drop is now becoming the child of my custom control but When i
compile the application after dropping a control say text box on my
custom control, the controls present on the template of custom control
disappear.
i have two controls defined in the template, a checkbox and an image.
There are two picture boxes as the property of the custom control too.
The property picture boxes (which i specify at the design time) remains
intact while those (check box and picture box) which are the part of
template disappear.

I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong now?

Regards
//Rizwan
Dave Sexton wrote:
Hi Rizwan,

To support drag & drap in the designer for your custom control you can
inherit from ContainerControl instead of Control or use the
DesignerAttribute as you have illustrated.

However, you won't be able to drag & drop controls into a Panel that is
within your control. Drag & drop support doesn't go that "deep".

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hello

i have made a custom control. i have placed a panel on it. I want this
panel to behave just like the normal panel. The problem i was having is
that the panel on my custom control doesnt accept other controls. The
control i drag drop on it becomes the child of my custom control's
parent form and not the child of my custom control. Then i added this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line does). Now
when i drag drop a control (say text box) onto the panel of my custom
control, the newly added control goes behind the custom control. It
becomes the child of my Custom control but i am unable to bring it to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that accepts other
control on design time (through drag drop) and behaves like ordinary
user control.

Regards
Rizwan
Jan 5 '07 #5

P: n/a
Hi Rizwan,

I'm curious to know whether the controls are being removed or simply hidden.

You may want to post some code as I mentioned in your other thread otherwise
it's going to be difficult, if not impossible, to help.

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hi Dave

lot of thanks for replying.

by template control i mean the controls which are added in its default
state, for example , the maximize minimze image, It is there in the
default state, and user can not change it in design time.

Disappearing controls: The controls (only default controls) disappear
when i compile the application. When i add my custom control to a form,
every thing is fine. i compiel the code, works fine. when i add
control from toolbar by drag drop, everything works fine. But as soon
as i compile the application (after adding control from toolbar), the
controls (only default controls) disappear. And ofcourse when i run the
application they are not visible too.

i have two default controls on custom control, one is check box and
other is picture box. I add these controls during the desiging of the
custom control (not the design time of form). I set the picture for
picture control and check the checkbox in the constructor of the custom
control. After building the code, my custom control is ready for use
with two default controls on it. Please note that there is also a group
box used as line seperator (it is also a default control). but this
group box doesnt disappear. on compile time

i hope the situation is clear now :)

Regards
Rizwan

Dave Sexton wrote:
>Hi Rizwan,

I don't really understand the problem.

By "template" do you mean your custom control in its default state when
it's
first added to a Form?

Are the disappearing controls disappearing in the designer, at runtime or
both?

Are you adding the disappearing controls to your custom control in its
constructor or upon some event such as Load? Are they even being added
by
the custom control itself?

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@51g2000cwl.googlegr oups.com...
Hello

i have now removed panel from my custom control. The control added by
drag drop is now becoming the child of my custom control but When i
compile the application after dropping a control say text box on my
custom control, the controls present on the template of custom control
disappear.
i have two controls defined in the template, a checkbox and an image.
There are two picture boxes as the property of the custom control too.
The property picture boxes (which i specify at the design time) remains
intact while those (check box and picture box) which are the part of
template disappear.

I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong now?

Regards
//Rizwan
Dave Sexton wrote:
Hi Rizwan,

To support drag & drap in the designer for your custom control you can
inherit from ContainerControl instead of Control or use the
DesignerAttribute as you have illustrated.

However, you won't be able to drag & drop controls into a Panel that
is
within your control. Drag & drop support doesn't go that "deep".

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googleg roups.com...
Hello

i have made a custom control. i have placed a panel on it. I want
this
panel to behave just like the normal panel. The problem i was having
is
that the panel on my custom control doesnt accept other controls.
The
control i drag drop on it becomes the child of my custom control's
parent form and not the child of my custom control. Then i added
this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line does).
Now
when i drag drop a control (say text box) onto the panel of my
custom
control, the newly added control goes behind the custom control. It
becomes the child of my Custom control but i am unable to bring it
to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that accepts other
control on design time (through drag drop) and behaves like ordinary
user control.

Regards
Rizwan


Jan 5 '07 #6

P: n/a
Hi Dave

yes you are right, i shouldnt have created new thread.

i read ur reply in new thread. i created simple application to
replicate the error. what i found now is the hiding of controls is
because of the change in size of custom control.

i try to make clear what is the problem now.

I place my custom control over the form. i compile it, everything works
fine. i resize my custom control (make it smaller), recompile it.
everything works fine.

now here comes the problem. I place my custom control over the form. i
compile it, everything works fine. i resize my custom control (make it
smaller), place control from toolbox over my custom control, recompile
it. The checkbox and image (which i mentioned in earlier posts) become
hidden (they are not deleted, they become hidden).

Now i am wondering what the control from toolbox does to my custom
control. The resizing (making smaller in size) works fine without
adding the control from toolbox.

Regards
//Rizwan

Dave Sexton wrote:
Hi Rizwan,

I'm curious to know whether the controls are being removed or simply hidden.

You may want to post some code as I mentioned in your other thread otherwise
it's going to be difficult, if not impossible, to help.

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hi Dave

lot of thanks for replying.

by template control i mean the controls which are added in its default
state, for example , the maximize minimze image, It is there in the
default state, and user can not change it in design time.

Disappearing controls: The controls (only default controls) disappear
when i compile the application. When i add my custom control to a form,
every thing is fine. i compiel the code, works fine. when i add
control from toolbar by drag drop, everything works fine. But as soon
as i compile the application (after adding control from toolbar), the
controls (only default controls) disappear. And ofcourse when i run the
application they are not visible too.

i have two default controls on custom control, one is check box and
other is picture box. I add these controls during the desiging of the
custom control (not the design time of form). I set the picture for
picture control and check the checkbox in the constructor of the custom
control. After building the code, my custom control is ready for use
with two default controls on it. Please note that there is also a group
box used as line seperator (it is also a default control). but this
group box doesnt disappear. on compile time

i hope the situation is clear now :)

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

I don't really understand the problem.

By "template" do you mean your custom control in its default state when
it's
first added to a Form?

Are the disappearing controls disappearing in the designer, at runtime or
both?

Are you adding the disappearing controls to your custom control in its
constructor or upon some event such as Load? Are they even being added
by
the custom control itself?

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
Hello

i have now removed panel from my custom control. The control added by
drag drop is now becoming the child of my custom control but When i
compile the application after dropping a control say text box on my
custom control, the controls present on the template of custom control
disappear.
i have two controls defined in the template, a checkbox and an image.
There are two picture boxes as the property of the custom control too.
The property picture boxes (which i specify at the design time) remains
intact while those (check box and picture box) which are the part of
template disappear.

I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong now?

Regards
//Rizwan
Dave Sexton wrote:
Hi Rizwan,

To support drag & drap in the designer for your custom control you can
inherit from ContainerControl instead of Control or use the
DesignerAttribute as you have illustrated.

However, you won't be able to drag & drop controls into a Panel that
is
within your control. Drag & drop support doesn't go that "deep".

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hello

i have made a custom control. i have placed a panel on it. I want
this
panel to behave just like the normal panel. The problem i was having
is
that the panel on my custom control doesnt accept other controls.
The
control i drag drop on it becomes the child of my custom control's
parent form and not the child of my custom control. Then i added
this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line does).
Now
when i drag drop a control (say text box) onto the panel of my
custom
control, the newly added control goes behind the custom control. It
becomes the child of my Custom control but i am unable to bring it
to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that accepts other
control on design time (through drag drop) and behaves like ordinary
user control.

Regards
Rizwan
Jan 5 '07 #7

P: n/a
Hi Rizwan,

At this point I doubt anyone will be able to help you without seeing some
simple code that reproduces the issue you are having. I can keep guessing,
but we probably won't get anywhere with it :)

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11*********************@51g2000cwl.googlegrou ps.com...
Hi Dave

yes you are right, i shouldnt have created new thread.

i read ur reply in new thread. i created simple application to
replicate the error. what i found now is the hiding of controls is
because of the change in size of custom control.

i try to make clear what is the problem now.

I place my custom control over the form. i compile it, everything works
fine. i resize my custom control (make it smaller), recompile it.
everything works fine.

now here comes the problem. I place my custom control over the form. i
compile it, everything works fine. i resize my custom control (make it
smaller), place control from toolbox over my custom control, recompile
it. The checkbox and image (which i mentioned in earlier posts) become
hidden (they are not deleted, they become hidden).

Now i am wondering what the control from toolbox does to my custom
control. The resizing (making smaller in size) works fine without
adding the control from toolbox.

Regards
//Rizwan

Dave Sexton wrote:
>Hi Rizwan,

I'm curious to know whether the controls are being removed or simply
hidden.

You may want to post some code as I mentioned in your other thread
otherwise
it's going to be difficult, if not impossible, to help.

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googleg roups.com...
Hi Dave

lot of thanks for replying.

by template control i mean the controls which are added in its default
state, for example , the maximize minimze image, It is there in the
default state, and user can not change it in design time.

Disappearing controls: The controls (only default controls) disappear
when i compile the application. When i add my custom control to a form,
every thing is fine. i compiel the code, works fine. when i add
control from toolbar by drag drop, everything works fine. But as soon
as i compile the application (after adding control from toolbar), the
controls (only default controls) disappear. And ofcourse when i run the
application they are not visible too.

i have two default controls on custom control, one is check box and
other is picture box. I add these controls during the desiging of the
custom control (not the design time of form). I set the picture for
picture control and check the checkbox in the constructor of the custom
control. After building the code, my custom control is ready for use
with two default controls on it. Please note that there is also a group
box used as line seperator (it is also a default control). but this
group box doesnt disappear. on compile time

i hope the situation is clear now :)

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

I don't really understand the problem.

By "template" do you mean your custom control in its default state
when
it's
first added to a Form?

Are the disappearing controls disappearing in the designer, at runtime
or
both?

Are you adding the disappearing controls to your custom control in its
constructor or upon some event such as Load? Are they even being
added
by
the custom control itself?

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@51g2000cwl.googlegr oups.com...
Hello

i have now removed panel from my custom control. The control added
by
drag drop is now becoming the child of my custom control but When i
compile the application after dropping a control say text box on my
custom control, the controls present on the template of custom
control
disappear.
i have two controls defined in the template, a checkbox and an
image.
There are two picture boxes as the property of the custom control
too.
The property picture boxes (which i specify at the design time)
remains
intact while those (check box and picture box) which are the part of
template disappear.

I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong now?

Regards
//Rizwan
Dave Sexton wrote:
Hi Rizwan,

To support drag & drap in the designer for your custom control you
can
inherit from ContainerControl instead of Control or use the
DesignerAttribute as you have illustrated.

However, you won't be able to drag & drop controls into a Panel
that
is
within your control. Drag & drop support doesn't go that "deep".

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googleg roups.com...
Hello

i have made a custom control. i have placed a panel on it. I want
this
panel to behave just like the normal panel. The problem i was
having
is
that the panel on my custom control doesnt accept other controls.
The
control i drag drop on it becomes the child of my custom
control's
parent form and not the child of my custom control. Then i added
this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line does).
Now
when i drag drop a control (say text box) onto the panel of my
custom
control, the newly added control goes behind the custom control.
It
becomes the child of my Custom control but i am unable to bring
it
to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that accepts
other
control on design time (through drag drop) and behaves like
ordinary
user control.

Regards
Rizwan

Jan 5 '07 #8

P: n/a
Hi Dave

Ok it seems like i know the problem now :) but not the solution. I am
going to re write the problem in relation to 'short but complete
program' that i have created. Code is appended at the end.

I have a custom control, which contains only one default control i.e.
check box. This checkbox is added into the template of custom control
and act as default control of my custom control. The checkbox is placed
to top right corner of custom control and is anchor is set to top right
corner too.

I add my custom control to a form and compile it. Now i resize (making
it smaller) from the top right corner towards centre. As the anchor of
the checkbox is set to top right, therefore it moves with the top right
corner. I compile the program. The custom box is now displayed smaller
in size with checkbox attached to top right corner. Everything is fine.

Now i repeat the same procedure after placing a control say Button from
toolbox on my custom control. When i am resizing the custom control
(making it smaller, moving from top right corner to centre) the
checkbox moves with the top right corner. Everything looks fine before
compiling. But when i compile the application, the checkbox is gone
(not displayed). I think it looses its anchor. when i again resize the
custom control (making it bigger enough to be at least of original size
by dragging the top right corner to the angle of 45 degree) the
checkbox is dispalyed again. Same happens with all default controls of
custom box.

My question now is that, why the toolbox control make default controls
of custom control loose their anchor? or is this really the anchor
problem or something else...

i am placing the code of two classes. i dont know whether this code is
enough or not.

///////////////////////////////////////
namespace tempPrj
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
///////////////////////////////////////

///////////////////////////////////////
namespace tempPrj
{
public partial class UserControl2 : ContainerControl
{
public UserControl2()
{
InitializeComponent();
checkBox1.Checked = true;
}
}
}
///////////////////////////////////////

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

At this point I doubt anyone will be able to help you without seeing some
simple code that reproduces the issue you are having. I can keep guessing,
but we probably won't get anywhere with it :)

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11*********************@51g2000cwl.googlegrou ps.com...
Hi Dave

yes you are right, i shouldnt have created new thread.

i read ur reply in new thread. i created simple application to
replicate the error. what i found now is the hiding of controls is
because of the change in size of custom control.

i try to make clear what is the problem now.

I place my custom control over the form. i compile it, everything works
fine. i resize my custom control (make it smaller), recompile it.
everything works fine.

now here comes the problem. I place my custom control over the form. i
compile it, everything works fine. i resize my custom control (make it
smaller), place control from toolbox over my custom control, recompile
it. The checkbox and image (which i mentioned in earlier posts) become
hidden (they are not deleted, they become hidden).

Now i am wondering what the control from toolbox does to my custom
control. The resizing (making smaller in size) works fine without
adding the control from toolbox.

Regards
//Rizwan

Dave Sexton wrote:
Hi Rizwan,

I'm curious to know whether the controls are being removed or simply
hidden.

You may want to post some code as I mentioned in your other thread
otherwise
it's going to be difficult, if not impossible, to help.

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hi Dave

lot of thanks for replying.

by template control i mean the controls which are added in its default
state, for example , the maximize minimze image, It is there in the
default state, and user can not change it in design time.

Disappearing controls: The controls (only default controls) disappear
when i compile the application. When i add my custom control to a form,
every thing is fine. i compiel the code, works fine. when i add
control from toolbar by drag drop, everything works fine. But as soon
as i compile the application (after adding control from toolbar), the
controls (only default controls) disappear. And ofcourse when i run the
application they are not visible too.

i have two default controls on custom control, one is check box and
other is picture box. I add these controls during the desiging of the
custom control (not the design time of form). I set the picture for
picture control and check the checkbox in the constructor of the custom
control. After building the code, my custom control is ready for use
with two default controls on it. Please note that there is also a group
box used as line seperator (it is also a default control). but this
group box doesnt disappear. on compile time

i hope the situation is clear now :)

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

I don't really understand the problem.

By "template" do you mean your custom control in its default state
when
it's
first added to a Form?

Are the disappearing controls disappearing in the designer, at runtime
or
both?

Are you adding the disappearing controls to your custom control in its
constructor or upon some event such as Load? Are they even being
added
by
the custom control itself?

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
Hello

i have now removed panel from my custom control. The control added
by
drag drop is now becoming the child of my custom control but When i
compile the application after dropping a control say text box on my
custom control, the controls present on the template of custom
control
disappear.
i have two controls defined in the template, a checkbox and an
image.
There are two picture boxes as the property of the custom control
too.
The property picture boxes (which i specify at the design time)
remains
intact while those (check box and picture box) which are the part of
template disappear.

I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong now?

Regards
//Rizwan
Dave Sexton wrote:
Hi Rizwan,

To support drag & drap in the designer for your custom control you
can
inherit from ContainerControl instead of Control or use the
DesignerAttribute as you have illustrated.

However, you won't be able to drag & drop controls into a Panel
that
is
within your control. Drag & drop support doesn't go that "deep".

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hello

i have made a custom control. i have placed a panel on it. I want
this
panel to behave just like the normal panel. The problem i was
having
is
that the panel on my custom control doesnt accept other controls.
The
control i drag drop on it becomes the child of my custom
control's
parent form and not the child of my custom control. Then i added
this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line does).
Now
when i drag drop a control (say text box) onto the panel of my
custom
control, the newly added control goes behind the custom control.
It
becomes the child of my Custom control but i am unable to bring
it
to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that accepts
other
control on design time (through drag drop) and behaves like
ordinary
user control.

Regards
Rizwan

Jan 8 '07 #9

P: n/a
Another thing i have found out is that the custom control resizes
itself at compile time. Even with resizing, it should work fine because
of anchor.
I can assign positions to control under resize event. but ofcourse this
is not a good way.

//Rizwan

ri***********@gmail.com wrote:
Hi Dave

Ok it seems like i know the problem now :) but not the solution. I am
going to re write the problem in relation to 'short but complete
program' that i have created. Code is appended at the end.

I have a custom control, which contains only one default control i.e.
check box. This checkbox is added into the template of custom control
and act as default control of my custom control. The checkbox is placed
to top right corner of custom control and is anchor is set to top right
corner too.

I add my custom control to a form and compile it. Now i resize (making
it smaller) from the top right corner towards centre. As the anchor of
the checkbox is set to top right, therefore it moves with the top right
corner. I compile the program. The custom box is now displayed smaller
in size with checkbox attached to top right corner. Everything is fine.

Now i repeat the same procedure after placing a control say Button from
toolbox on my custom control. When i am resizing the custom control
(making it smaller, moving from top right corner to centre) the
checkbox moves with the top right corner. Everything looks fine before
compiling. But when i compile the application, the checkbox is gone
(not displayed). I think it looses its anchor. when i again resize the
custom control (making it bigger enough to be at least of original size
by dragging the top right corner to the angle of 45 degree) the
checkbox is dispalyed again. Same happens with all default controls of
custom box.

My question now is that, why the toolbox control make default controls
of custom control loose their anchor? or is this really the anchor
problem or something else...

i am placing the code of two classes. i dont know whether this code is
enough or not.

///////////////////////////////////////
namespace tempPrj
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
///////////////////////////////////////

///////////////////////////////////////
namespace tempPrj
{
public partial class UserControl2 : ContainerControl
{
public UserControl2()
{
InitializeComponent();
checkBox1.Checked = true;
}
}
}
///////////////////////////////////////

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

At this point I doubt anyone will be able to help you without seeing some
simple code that reproduces the issue you are having. I can keep guessing,
but we probably won't get anywhere with it :)

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11*********************@51g2000cwl.googlegrou ps.com...
Hi Dave
>
yes you are right, i shouldnt have created new thread.
>
i read ur reply in new thread. i created simple application to
replicate the error. what i found now is the hiding of controls is
because of the change in size of custom control.
>
i try to make clear what is the problem now.
>
I place my custom control over the form. i compile it, everything works
fine. i resize my custom control (make it smaller), recompile it.
everything works fine.
>
now here comes the problem. I place my custom control over the form. i
compile it, everything works fine. i resize my custom control (make it
smaller), place control from toolbox over my custom control, recompile
it. The checkbox and image (which i mentioned in earlier posts) become
hidden (they are not deleted, they become hidden).
>
Now i am wondering what the control from toolbox does to my custom
control. The resizing (making smaller in size) works fine without
adding the control from toolbox.
>
Regards
//Rizwan
>
Dave Sexton wrote:
>Hi Rizwan,
>>
>I'm curious to know whether the controls are being removed or simply
>hidden.
>>
>You may want to post some code as I mentioned in your other thread
>otherwise
>it's going to be difficult, if not impossible, to help.
>>
>--
>Dave Sexton
>http://davesexton.com/blog
>>
><ri***********@gmail.comwrote in message
>news:11**********************@v33g2000cwv.googleg roups.com...
Hi Dave
>
lot of thanks for replying.
>
by template control i mean the controls which are added in its default
state, for example , the maximize minimze image, It is there in the
default state, and user can not change it in design time.
>
Disappearing controls: The controls (only default controls) disappear
when i compile the application. When i add my custom control to a form,
every thing is fine. i compiel the code, works fine. when i add
control from toolbar by drag drop, everything works fine. But as soon
as i compile the application (after adding control from toolbar), the
controls (only default controls) disappear. And ofcourse when i run the
application they are not visible too.
>
i have two default controls on custom control, one is check box and
other is picture box. I add these controls during the desiging of the
custom control (not the design time of form). I set the picture for
picture control and check the checkbox in the constructor of the custom
control. After building the code, my custom control is ready for use
with two default controls on it. Please note that there is also a group
box used as line seperator (it is also a default control). but this
group box doesnt disappear. on compile time
>
i hope the situation is clear now :)
>
Regards
Rizwan
>
Dave Sexton wrote:
>Hi Rizwan,
>>
>I don't really understand the problem.
>>
>By "template" do you mean your custom control in its default state
>when
>it's
>first added to a Form?
>>
>Are the disappearing controls disappearing in the designer, at runtime
>or
>both?
>>
>Are you adding the disappearing controls to your custom control in its
>constructor or upon some event such as Load? Are they even being
>added
>by
>the custom control itself?
>>
>--
>Dave Sexton
>http://davesexton.com/blog
>>
><ri***********@gmail.comwrote in message
>news:11**********************@51g2000cwl.googlegr oups.com...
Hello
>
i have now removed panel from my custom control. The control added
by
drag drop is now becoming the child of my custom control but When i
compile the application after dropping a control say text box on my
custom control, the controls present on the template of custom
control
disappear.
i have two controls defined in the template, a checkbox and an
image.
There are two picture boxes as the property of the custom control
too.
The property picture boxes (which i specify at the design time)
remains
intact while those (check box and picture box) which are the part of
template disappear.
>
I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong now?
>
Regards
//Rizwan
>
>
Dave Sexton wrote:
>Hi Rizwan,
>>
>To support drag & drap in the designer for your custom control you
>can
>inherit from ContainerControl instead of Control or use the
>DesignerAttribute as you have illustrated.
>>
>However, you won't be able to drag & drop controls into a Panel
>that
>is
>within your control. Drag & drop support doesn't go that "deep".
>>
>--
>Dave Sexton
>http://davesexton.com/blog
>>
><ri***********@gmail.comwrote in message
>news:11**********************@v33g2000cwv.googleg roups.com...
Hello
>
i have made a custom control. i have placed a panel on it. I want
this
panel to behave just like the normal panel. The problem i was
having
is
that the panel on my custom control doesnt accept other controls.
The
control i drag drop on it becomes the child of my custom
control's
parent form and not the child of my custom control. Then i added
this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line does).
Now
when i drag drop a control (say text box) onto the panel of my
custom
control, the newly added control goes behind the custom control.
It
becomes the child of my Custom control but i am unable to bring
it
to
front. Also my custom control becomes distorted.
>
To summarize all. I want to have a custom control that accepts
other
control on design time (through drag drop) and behaves like
ordinary
user control.
>
Regards
Rizwan
>
>
>
>
Jan 8 '07 #10

P: n/a
Another thing i have found out is that the custom control resizes
itself at compile time. Even with resizing, it should work fine because
of anchor.
I can assign positions to control under resize event. but ofcourse this
is not a good way.

//Rizwan

ri***********@gmail.com wrote:
Hi Dave

Ok it seems like i know the problem now :) but not the solution. I am
going to re write the problem in relation to 'short but complete
program' that i have created. Code is appended at the end.

I have a custom control, which contains only one default control i.e.
check box. This checkbox is added into the template of custom control
and act as default control of my custom control. The checkbox is placed
to top right corner of custom control and is anchor is set to top right
corner too.

I add my custom control to a form and compile it. Now i resize (making
it smaller) from the top right corner towards centre. As the anchor of
the checkbox is set to top right, therefore it moves with the top right
corner. I compile the program. The custom box is now displayed smaller
in size with checkbox attached to top right corner. Everything is fine.

Now i repeat the same procedure after placing a control say Button from
toolbox on my custom control. When i am resizing the custom control
(making it smaller, moving from top right corner to centre) the
checkbox moves with the top right corner. Everything looks fine before
compiling. But when i compile the application, the checkbox is gone
(not displayed). I think it looses its anchor. when i again resize the
custom control (making it bigger enough to be at least of original size
by dragging the top right corner to the angle of 45 degree) the
checkbox is dispalyed again. Same happens with all default controls of
custom box.

My question now is that, why the toolbox control make default controls
of custom control loose their anchor? or is this really the anchor
problem or something else...

i am placing the code of two classes. i dont know whether this code is
enough or not.

///////////////////////////////////////
namespace tempPrj
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
///////////////////////////////////////

///////////////////////////////////////
namespace tempPrj
{
public partial class UserControl2 : ContainerControl
{
public UserControl2()
{
InitializeComponent();
checkBox1.Checked = true;
}
}
}
///////////////////////////////////////

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

At this point I doubt anyone will be able to help you without seeing some
simple code that reproduces the issue you are having. I can keep guessing,
but we probably won't get anywhere with it :)

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11*********************@51g2000cwl.googlegrou ps.com...
Hi Dave
>
yes you are right, i shouldnt have created new thread.
>
i read ur reply in new thread. i created simple application to
replicate the error. what i found now is the hiding of controls is
because of the change in size of custom control.
>
i try to make clear what is the problem now.
>
I place my custom control over the form. i compile it, everything works
fine. i resize my custom control (make it smaller), recompile it.
everything works fine.
>
now here comes the problem. I place my custom control over the form. i
compile it, everything works fine. i resize my custom control (make it
smaller), place control from toolbox over my custom control, recompile
it. The checkbox and image (which i mentioned in earlier posts) become
hidden (they are not deleted, they become hidden).
>
Now i am wondering what the control from toolbox does to my custom
control. The resizing (making smaller in size) works fine without
adding the control from toolbox.
>
Regards
//Rizwan
>
Dave Sexton wrote:
>Hi Rizwan,
>>
>I'm curious to know whether the controls are being removed or simply
>hidden.
>>
>You may want to post some code as I mentioned in your other thread
>otherwise
>it's going to be difficult, if not impossible, to help.
>>
>--
>Dave Sexton
>http://davesexton.com/blog
>>
><ri***********@gmail.comwrote in message
>news:11**********************@v33g2000cwv.googleg roups.com...
Hi Dave
>
lot of thanks for replying.
>
by template control i mean the controls which are added in its default
state, for example , the maximize minimze image, It is there in the
default state, and user can not change it in design time.
>
Disappearing controls: The controls (only default controls) disappear
when i compile the application. When i add my custom control to a form,
every thing is fine. i compiel the code, works fine. when i add
control from toolbar by drag drop, everything works fine. But as soon
as i compile the application (after adding control from toolbar), the
controls (only default controls) disappear. And ofcourse when i run the
application they are not visible too.
>
i have two default controls on custom control, one is check box and
other is picture box. I add these controls during the desiging of the
custom control (not the design time of form). I set the picture for
picture control and check the checkbox in the constructor of the custom
control. After building the code, my custom control is ready for use
with two default controls on it. Please note that there is also a group
box used as line seperator (it is also a default control). but this
group box doesnt disappear. on compile time
>
i hope the situation is clear now :)
>
Regards
Rizwan
>
Dave Sexton wrote:
>Hi Rizwan,
>>
>I don't really understand the problem.
>>
>By "template" do you mean your custom control in its default state
>when
>it's
>first added to a Form?
>>
>Are the disappearing controls disappearing in the designer, at runtime
>or
>both?
>>
>Are you adding the disappearing controls to your custom control in its
>constructor or upon some event such as Load? Are they even being
>added
>by
>the custom control itself?
>>
>--
>Dave Sexton
>http://davesexton.com/blog
>>
><ri***********@gmail.comwrote in message
>news:11**********************@51g2000cwl.googlegr oups.com...
Hello
>
i have now removed panel from my custom control. The control added
by
drag drop is now becoming the child of my custom control but When i
compile the application after dropping a control say text box on my
custom control, the controls present on the template of custom
control
disappear.
i have two controls defined in the template, a checkbox and an
image.
There are two picture boxes as the property of the custom control
too.
The property picture boxes (which i specify at the design time)
remains
intact while those (check box and picture box) which are the part of
template disappear.
>
I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong now?
>
Regards
//Rizwan
>
>
Dave Sexton wrote:
>Hi Rizwan,
>>
>To support drag & drap in the designer for your custom control you
>can
>inherit from ContainerControl instead of Control or use the
>DesignerAttribute as you have illustrated.
>>
>However, you won't be able to drag & drop controls into a Panel
>that
>is
>within your control. Drag & drop support doesn't go that "deep".
>>
>--
>Dave Sexton
>http://davesexton.com/blog
>>
><ri***********@gmail.comwrote in message
>news:11**********************@v33g2000cwv.googleg roups.com...
Hello
>
i have made a custom control. i have placed a panel on it. I want
this
panel to behave just like the normal panel. The problem i was
having
is
that the panel on my custom control doesnt accept other controls.
The
control i drag drop on it becomes the child of my custom
control's
parent form and not the child of my custom control. Then i added
this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line does).
Now
when i drag drop a control (say text box) onto the panel of my
custom
control, the newly added control goes behind the custom control.
It
becomes the child of my Custom control but i am unable to bring
it
to
front. Also my custom control becomes distorted.
>
To summarize all. I want to have a custom control that accepts
other
control on design time (through drag drop) and behaves like
ordinary
user control.
>
Regards
Rizwan
>
>
>
>
Jan 8 '07 #11

P: n/a
Hi,

I was able to reproduce the problem:

1. Create a UserControl
2. Add a CheckBox
3. Change the class to derive from ContainerControl in code
4. Build.
5. Create a Form
6. Add the custom control to the Form
7. Add a TextBox to the custom control in the Form designer
8. Build and run.

Controls defined in the custom control disappear at runtime and in the
designer; however, controls added to the custom conrol in the Form persist.

This behavior appears to be the fault of the ContainerControl's designer. A
workaround is to derive your control from Panel instead.

HTH

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@q40g2000cwq.googlegr oups.com...
Hi Dave

Ok it seems like i know the problem now :) but not the solution. I am
going to re write the problem in relation to 'short but complete
program' that i have created. Code is appended at the end.

I have a custom control, which contains only one default control i.e.
check box. This checkbox is added into the template of custom control
and act as default control of my custom control. The checkbox is placed
to top right corner of custom control and is anchor is set to top right
corner too.

I add my custom control to a form and compile it. Now i resize (making
it smaller) from the top right corner towards centre. As the anchor of
the checkbox is set to top right, therefore it moves with the top right
corner. I compile the program. The custom box is now displayed smaller
in size with checkbox attached to top right corner. Everything is fine.

Now i repeat the same procedure after placing a control say Button from
toolbox on my custom control. When i am resizing the custom control
(making it smaller, moving from top right corner to centre) the
checkbox moves with the top right corner. Everything looks fine before
compiling. But when i compile the application, the checkbox is gone
(not displayed). I think it looses its anchor. when i again resize the
custom control (making it bigger enough to be at least of original size
by dragging the top right corner to the angle of 45 degree) the
checkbox is dispalyed again. Same happens with all default controls of
custom box.

My question now is that, why the toolbox control make default controls
of custom control loose their anchor? or is this really the anchor
problem or something else...

i am placing the code of two classes. i dont know whether this code is
enough or not.

///////////////////////////////////////
namespace tempPrj
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
///////////////////////////////////////

///////////////////////////////////////
namespace tempPrj
{
public partial class UserControl2 : ContainerControl
{
public UserControl2()
{
InitializeComponent();
checkBox1.Checked = true;
}
}
}
///////////////////////////////////////

Regards
Rizwan

Dave Sexton wrote:
>Hi Rizwan,

At this point I doubt anyone will be able to help you without seeing some
simple code that reproduces the issue you are having. I can keep
guessing,
but we probably won't get anywhere with it :)

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11*********************@51g2000cwl.googlegro ups.com...
Hi Dave

yes you are right, i shouldnt have created new thread.

i read ur reply in new thread. i created simple application to
replicate the error. what i found now is the hiding of controls is
because of the change in size of custom control.

i try to make clear what is the problem now.

I place my custom control over the form. i compile it, everything works
fine. i resize my custom control (make it smaller), recompile it.
everything works fine.

now here comes the problem. I place my custom control over the form. i
compile it, everything works fine. i resize my custom control (make it
smaller), place control from toolbox over my custom control, recompile
it. The checkbox and image (which i mentioned in earlier posts) become
hidden (they are not deleted, they become hidden).

Now i am wondering what the control from toolbox does to my custom
control. The resizing (making smaller in size) works fine without
adding the control from toolbox.

Regards
//Rizwan

Dave Sexton wrote:
Hi Rizwan,

I'm curious to know whether the controls are being removed or simply
hidden.

You may want to post some code as I mentioned in your other thread
otherwise
it's going to be difficult, if not impossible, to help.

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googleg roups.com...
Hi Dave

lot of thanks for replying.

by template control i mean the controls which are added in its
default
state, for example , the maximize minimze image, It is there in the
default state, and user can not change it in design time.

Disappearing controls: The controls (only default controls)
disappear
when i compile the application. When i add my custom control to a
form,
every thing is fine. i compiel the code, works fine. when i add
control from toolbar by drag drop, everything works fine. But as
soon
as i compile the application (after adding control from toolbar),
the
controls (only default controls) disappear. And ofcourse when i run
the
application they are not visible too.

i have two default controls on custom control, one is check box and
other is picture box. I add these controls during the desiging of
the
custom control (not the design time of form). I set the picture for
picture control and check the checkbox in the constructor of the
custom
control. After building the code, my custom control is ready for use
with two default controls on it. Please note that there is also a
group
box used as line seperator (it is also a default control). but this
group box doesnt disappear. on compile time

i hope the situation is clear now :)

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

I don't really understand the problem.

By "template" do you mean your custom control in its default state
when
it's
first added to a Form?

Are the disappearing controls disappearing in the designer, at
runtime
or
both?

Are you adding the disappearing controls to your custom control in
its
constructor or upon some event such as Load? Are they even being
added
by
the custom control itself?

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@51g2000cwl.googlegr oups.com...
Hello

i have now removed panel from my custom control. The control
added
by
drag drop is now becoming the child of my custom control but When
i
compile the application after dropping a control say text box on
my
custom control, the controls present on the template of custom
control
disappear.
i have two controls defined in the template, a checkbox and an
image.
There are two picture boxes as the property of the custom control
too.
The property picture boxes (which i specify at the design time)
remains
intact while those (check box and picture box) which are the part
of
template disappear.

I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong
now?

Regards
//Rizwan
Dave Sexton wrote:
Hi Rizwan,

To support drag & drap in the designer for your custom control
you
can
inherit from ContainerControl instead of Control or use the
DesignerAttribute as you have illustrated.

However, you won't be able to drag & drop controls into a Panel
that
is
within your control. Drag & drop support doesn't go that
"deep".

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googleg roups.com...
Hello

i have made a custom control. i have placed a panel on it. I
want
this
panel to behave just like the normal panel. The problem i was
having
is
that the panel on my custom control doesnt accept other
controls.
The
control i drag drop on it becomes the child of my custom
control's
parent form and not the child of my custom control. Then i
added
this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line
does).
Now
when i drag drop a control (say text box) onto the panel of my
custom
control, the newly added control goes behind the custom
control.
It
becomes the child of my Custom control but i am unable to
bring
it
to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that accepts
other
control on design time (through drag drop) and behaves like
ordinary
user control.

Regards
Rizwan


Jan 9 '07 #12

P: n/a
Hi

the steps you mentioned dont talk about the resizing of custom control
on the Form in Form Designer. Control defined in the custom control
only disappear if i resize the custom control (make is smaller).

If i strickly follow steps you mentioend (without resizing) then
everything works fine.

Add this step between 8 and 9. i.e. Decrease the size of custom control
such that the control defined on custom control lies out side the
boundry of new size.

i have already tried driving my custom control from panel too, it
doesnt work.

Regards
Rizwan

Dave Sexton wrote:
Hi,

I was able to reproduce the problem:

1. Create a UserControl
2. Add a CheckBox
3. Change the class to derive from ContainerControl in code
4. Build.
5. Create a Form
6. Add the custom control to the Form
7. Add a TextBox to the custom control in the Form designer
8. Build and run.

Controls defined in the custom control disappear at runtime and in the
designer; however, controls added to the custom conrol in the Form persist.

This behavior appears to be the fault of the ContainerControl's designer. A
workaround is to derive your control from Panel instead.

HTH

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@q40g2000cwq.googlegr oups.com...
Hi Dave

Ok it seems like i know the problem now :) but not the solution. I am
going to re write the problem in relation to 'short but complete
program' that i have created. Code is appended at the end.

I have a custom control, which contains only one default control i.e.
check box. This checkbox is added into the template of custom control
and act as default control of my custom control. The checkbox is placed
to top right corner of custom control and is anchor is set to top right
corner too.

I add my custom control to a form and compile it. Now i resize (making
it smaller) from the top right corner towards centre. As the anchor of
the checkbox is set to top right, therefore it moves with the top right
corner. I compile the program. The custom box is now displayed smaller
in size with checkbox attached to top right corner. Everything is fine.

Now i repeat the same procedure after placing a control say Button from
toolbox on my custom control. When i am resizing the custom control
(making it smaller, moving from top right corner to centre) the
checkbox moves with the top right corner. Everything looks fine before
compiling. But when i compile the application, the checkbox is gone
(not displayed). I think it looses its anchor. when i again resize the
custom control (making it bigger enough to be at least of original size
by dragging the top right corner to the angle of 45 degree) the
checkbox is dispalyed again. Same happens with all default controls of
custom box.

My question now is that, why the toolbox control make default controls
of custom control loose their anchor? or is this really the anchor
problem or something else...

i am placing the code of two classes. i dont know whether this code is
enough or not.

///////////////////////////////////////
namespace tempPrj
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
///////////////////////////////////////

///////////////////////////////////////
namespace tempPrj
{
public partial class UserControl2 : ContainerControl
{
public UserControl2()
{
InitializeComponent();
checkBox1.Checked = true;
}
}
}
///////////////////////////////////////

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

At this point I doubt anyone will be able to help you without seeing some
simple code that reproduces the issue you are having. I can keep
guessing,
but we probably won't get anywhere with it :)

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11*********************@51g2000cwl.googlegrou ps.com...
Hi Dave

yes you are right, i shouldnt have created new thread.

i read ur reply in new thread. i created simple application to
replicate the error. what i found now is the hiding of controls is
because of the change in size of custom control.

i try to make clear what is the problem now.

I place my custom control over the form. i compile it, everything works
fine. i resize my custom control (make it smaller), recompile it.
everything works fine.

now here comes the problem. I place my custom control over the form. i
compile it, everything works fine. i resize my custom control (make it
smaller), place control from toolbox over my custom control, recompile
it. The checkbox and image (which i mentioned in earlier posts) become
hidden (they are not deleted, they become hidden).

Now i am wondering what the control from toolbox does to my custom
control. The resizing (making smaller in size) works fine without
adding the control from toolbox.

Regards
//Rizwan

Dave Sexton wrote:
Hi Rizwan,

I'm curious to know whether the controls are being removed or simply
hidden.

You may want to post some code as I mentioned in your other thread
otherwise
it's going to be difficult, if not impossible, to help.

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hi Dave

lot of thanks for replying.

by template control i mean the controls which are added in its
default
state, for example , the maximize minimze image, It is there in the
default state, and user can not change it in design time.

Disappearing controls: The controls (only default controls)
disappear
when i compile the application. When i add my custom control to a
form,
every thing is fine. i compiel the code, works fine. when i add
control from toolbar by drag drop, everything works fine. But as
soon
as i compile the application (after adding control from toolbar),
the
controls (only default controls) disappear. And ofcourse when i run
the
application they are not visible too.

i have two default controls on custom control, one is check box and
other is picture box. I add these controls during the desiging of
the
custom control (not the design time of form). I set the picture for
picture control and check the checkbox in the constructor of the
custom
control. After building the code, my custom control is ready for use
with two default controls on it. Please note that there is also a
group
box used as line seperator (it is also a default control). but this
group box doesnt disappear. on compile time

i hope the situation is clear now :)

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

I don't really understand the problem.

By "template" do you mean your custom control in its default state
when
it's
first added to a Form?

Are the disappearing controls disappearing in the designer, at
runtime
or
both?

Are you adding the disappearing controls to your custom control in
its
constructor or upon some event such as Load? Are they even being
added
by
the custom control itself?

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
Hello

i have now removed panel from my custom control. The control
added
by
drag drop is now becoming the child of my custom control but When
i
compile the application after dropping a control say text box on
my
custom control, the controls present on the template of custom
control
disappear.
i have two controls defined in the template, a checkbox and an
image.
There are two picture boxes as the property of the custom control
too.
The property picture boxes (which i specify at the design time)
remains
intact while those (check box and picture box) which are the part
of
template disappear.

I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong
now?

Regards
//Rizwan
Dave Sexton wrote:
Hi Rizwan,

To support drag & drap in the designer for your custom control
you
can
inherit from ContainerControl instead of Control or use the
DesignerAttribute as you have illustrated.

However, you won't be able to drag & drop controls into a Panel
that
is
within your control. Drag & drop support doesn't go that
"deep".

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hello

i have made a custom control. i have placed a panel on it. I
want
this
panel to behave just like the normal panel. The problem i was
having
is
that the panel on my custom control doesnt accept other
controls.
The
control i drag drop on it becomes the child of my custom
control's
parent form and not the child of my custom control. Then i
added
this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line
does).
Now
when i drag drop a control (say text box) onto the panel of my
custom
control, the newly added control goes behind the custom
control.
It
becomes the child of my Custom control but i am unable to
bring
it
to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that accepts
other
control on design time (through drag drop) and behaves like
ordinary
user control.

Regards
Rizwan


Jan 9 '07 #13

P: n/a
Hi

download 'short complete' program from here
http://download.yousendit.com/09615D3C279284F9

thanks
//Rizwan

Dave Sexton wrote:
Hi,

I was able to reproduce the problem:

1. Create a UserControl
2. Add a CheckBox
3. Change the class to derive from ContainerControl in code
4. Build.
5. Create a Form
6. Add the custom control to the Form
7. Add a TextBox to the custom control in the Form designer
8. Build and run.

Controls defined in the custom control disappear at runtime and in the
designer; however, controls added to the custom conrol in the Form persist.

This behavior appears to be the fault of the ContainerControl's designer. A
workaround is to derive your control from Panel instead.

HTH

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@q40g2000cwq.googlegr oups.com...
Hi Dave

Ok it seems like i know the problem now :) but not the solution. I am
going to re write the problem in relation to 'short but complete
program' that i have created. Code is appended at the end.

I have a custom control, which contains only one default control i.e.
check box. This checkbox is added into the template of custom control
and act as default control of my custom control. The checkbox is placed
to top right corner of custom control and is anchor is set to top right
corner too.

I add my custom control to a form and compile it. Now i resize (making
it smaller) from the top right corner towards centre. As the anchor of
the checkbox is set to top right, therefore it moves with the top right
corner. I compile the program. The custom box is now displayed smaller
in size with checkbox attached to top right corner. Everything is fine.

Now i repeat the same procedure after placing a control say Button from
toolbox on my custom control. When i am resizing the custom control
(making it smaller, moving from top right corner to centre) the
checkbox moves with the top right corner. Everything looks fine before
compiling. But when i compile the application, the checkbox is gone
(not displayed). I think it looses its anchor. when i again resize the
custom control (making it bigger enough to be at least of original size
by dragging the top right corner to the angle of 45 degree) the
checkbox is dispalyed again. Same happens with all default controls of
custom box.

My question now is that, why the toolbox control make default controls
of custom control loose their anchor? or is this really the anchor
problem or something else...

i am placing the code of two classes. i dont know whether this code is
enough or not.

///////////////////////////////////////
namespace tempPrj
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
///////////////////////////////////////

///////////////////////////////////////
namespace tempPrj
{
public partial class UserControl2 : ContainerControl
{
public UserControl2()
{
InitializeComponent();
checkBox1.Checked = true;
}
}
}
///////////////////////////////////////

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

At this point I doubt anyone will be able to help you without seeing some
simple code that reproduces the issue you are having. I can keep
guessing,
but we probably won't get anywhere with it :)

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11*********************@51g2000cwl.googlegrou ps.com...
Hi Dave

yes you are right, i shouldnt have created new thread.

i read ur reply in new thread. i created simple application to
replicate the error. what i found now is the hiding of controls is
because of the change in size of custom control.

i try to make clear what is the problem now.

I place my custom control over the form. i compile it, everything works
fine. i resize my custom control (make it smaller), recompile it.
everything works fine.

now here comes the problem. I place my custom control over the form. i
compile it, everything works fine. i resize my custom control (make it
smaller), place control from toolbox over my custom control, recompile
it. The checkbox and image (which i mentioned in earlier posts) become
hidden (they are not deleted, they become hidden).

Now i am wondering what the control from toolbox does to my custom
control. The resizing (making smaller in size) works fine without
adding the control from toolbox.

Regards
//Rizwan

Dave Sexton wrote:
Hi Rizwan,

I'm curious to know whether the controls are being removed or simply
hidden.

You may want to post some code as I mentioned in your other thread
otherwise
it's going to be difficult, if not impossible, to help.

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hi Dave

lot of thanks for replying.

by template control i mean the controls which are added in its
default
state, for example , the maximize minimze image, It is there in the
default state, and user can not change it in design time.

Disappearing controls: The controls (only default controls)
disappear
when i compile the application. When i add my custom control to a
form,
every thing is fine. i compiel the code, works fine. when i add
control from toolbar by drag drop, everything works fine. But as
soon
as i compile the application (after adding control from toolbar),
the
controls (only default controls) disappear. And ofcourse when i run
the
application they are not visible too.

i have two default controls on custom control, one is check box and
other is picture box. I add these controls during the desiging of
the
custom control (not the design time of form). I set the picture for
picture control and check the checkbox in the constructor of the
custom
control. After building the code, my custom control is ready for use
with two default controls on it. Please note that there is also a
group
box used as line seperator (it is also a default control). but this
group box doesnt disappear. on compile time

i hope the situation is clear now :)

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

I don't really understand the problem.

By "template" do you mean your custom control in its default state
when
it's
first added to a Form?

Are the disappearing controls disappearing in the designer, at
runtime
or
both?

Are you adding the disappearing controls to your custom control in
its
constructor or upon some event such as Load? Are they even being
added
by
the custom control itself?

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
Hello

i have now removed panel from my custom control. The control
added
by
drag drop is now becoming the child of my custom control but When
i
compile the application after dropping a control say text box on
my
custom control, the controls present on the template of custom
control
disappear.
i have two controls defined in the template, a checkbox and an
image.
There are two picture boxes as the property of the custom control
too.
The property picture boxes (which i specify at the design time)
remains
intact while those (check box and picture box) which are the part
of
template disappear.

I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong
now?

Regards
//Rizwan
Dave Sexton wrote:
Hi Rizwan,

To support drag & drap in the designer for your custom control
you
can
inherit from ContainerControl instead of Control or use the
DesignerAttribute as you have illustrated.

However, you won't be able to drag & drop controls into a Panel
that
is
within your control. Drag & drop support doesn't go that
"deep".

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hello

i have made a custom control. i have placed a panel on it. I
want
this
panel to behave just like the normal panel. The problem i was
having
is
that the panel on my custom control doesnt accept other
controls.
The
control i drag drop on it becomes the child of my custom
control's
parent form and not the child of my custom control. Then i
added
this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line
does).
Now
when i drag drop a control (say text box) onto the panel of my
custom
control, the newly added control goes behind the custom
control.
It
becomes the child of my Custom control but i am unable to
bring
it
to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that accepts
other
control on design time (through drag drop) and behaves like
ordinary
user control.

Regards
Rizwan


Jan 9 '07 #14

P: n/a
Hi,

That's strange. The steps I gave behaved exactly as I mentioned. No
resizing was required and deriving from Panel solved the problem. I'll take
a look at your code from your adjacent post and get back to you.

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@i15g2000cwa.googlegr oups.com...
Hi

the steps you mentioned dont talk about the resizing of custom control
on the Form in Form Designer. Control defined in the custom control
only disappear if i resize the custom control (make is smaller).

If i strickly follow steps you mentioend (without resizing) then
everything works fine.

Add this step between 8 and 9. i.e. Decrease the size of custom control
such that the control defined on custom control lies out side the
boundry of new size.

i have already tried driving my custom control from panel too, it
doesnt work.

Regards
Rizwan

Dave Sexton wrote:
>Hi,

I was able to reproduce the problem:

1. Create a UserControl
2. Add a CheckBox
3. Change the class to derive from ContainerControl in code
4. Build.
5. Create a Form
6. Add the custom control to the Form
7. Add a TextBox to the custom control in the Form designer
8. Build and run.

Controls defined in the custom control disappear at runtime and in the
designer; however, controls added to the custom conrol in the Form
persist.

This behavior appears to be the fault of the ContainerControl's designer.
A
workaround is to derive your control from Panel instead.

HTH

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@q40g2000cwq.googleg roups.com...
Hi Dave

Ok it seems like i know the problem now :) but not the solution. I am
going to re write the problem in relation to 'short but complete
program' that i have created. Code is appended at the end.

I have a custom control, which contains only one default control i.e.
check box. This checkbox is added into the template of custom control
and act as default control of my custom control. The checkbox is placed
to top right corner of custom control and is anchor is set to top right
corner too.

I add my custom control to a form and compile it. Now i resize (making
it smaller) from the top right corner towards centre. As the anchor of
the checkbox is set to top right, therefore it moves with the top right
corner. I compile the program. The custom box is now displayed smaller
in size with checkbox attached to top right corner. Everything is fine.

Now i repeat the same procedure after placing a control say Button from
toolbox on my custom control. When i am resizing the custom control
(making it smaller, moving from top right corner to centre) the
checkbox moves with the top right corner. Everything looks fine before
compiling. But when i compile the application, the checkbox is gone
(not displayed). I think it looses its anchor. when i again resize the
custom control (making it bigger enough to be at least of original size
by dragging the top right corner to the angle of 45 degree) the
checkbox is dispalyed again. Same happens with all default controls of
custom box.

My question now is that, why the toolbox control make default controls
of custom control loose their anchor? or is this really the anchor
problem or something else...

i am placing the code of two classes. i dont know whether this code is
enough or not.

///////////////////////////////////////
namespace tempPrj
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
///////////////////////////////////////

///////////////////////////////////////
namespace tempPrj
{
public partial class UserControl2 : ContainerControl
{
public UserControl2()
{
InitializeComponent();
checkBox1.Checked = true;
}
}
}
///////////////////////////////////////

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

At this point I doubt anyone will be able to help you without seeing
some
simple code that reproduces the issue you are having. I can keep
guessing,
but we probably won't get anywhere with it :)

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11*********************@51g2000cwl.googlegro ups.com...
Hi Dave

yes you are right, i shouldnt have created new thread.

i read ur reply in new thread. i created simple application to
replicate the error. what i found now is the hiding of controls is
because of the change in size of custom control.

i try to make clear what is the problem now.

I place my custom control over the form. i compile it, everything
works
fine. i resize my custom control (make it smaller), recompile it.
everything works fine.

now here comes the problem. I place my custom control over the form.
i
compile it, everything works fine. i resize my custom control (make
it
smaller), place control from toolbox over my custom control,
recompile
it. The checkbox and image (which i mentioned in earlier posts)
become
hidden (they are not deleted, they become hidden).

Now i am wondering what the control from toolbox does to my custom
control. The resizing (making smaller in size) works fine without
adding the control from toolbox.

Regards
//Rizwan

Dave Sexton wrote:
Hi Rizwan,

I'm curious to know whether the controls are being removed or
simply
hidden.

You may want to post some code as I mentioned in your other thread
otherwise
it's going to be difficult, if not impossible, to help.

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googleg roups.com...
Hi Dave

lot of thanks for replying.

by template control i mean the controls which are added in its
default
state, for example , the maximize minimze image, It is there in
the
default state, and user can not change it in design time.

Disappearing controls: The controls (only default controls)
disappear
when i compile the application. When i add my custom control to a
form,
every thing is fine. i compiel the code, works fine. when i add
control from toolbar by drag drop, everything works fine. But as
soon
as i compile the application (after adding control from toolbar),
the
controls (only default controls) disappear. And ofcourse when i
run
the
application they are not visible too.

i have two default controls on custom control, one is check box
and
other is picture box. I add these controls during the desiging of
the
custom control (not the design time of form). I set the picture
for
picture control and check the checkbox in the constructor of the
custom
control. After building the code, my custom control is ready for
use
with two default controls on it. Please note that there is also a
group
box used as line seperator (it is also a default control). but
this
group box doesnt disappear. on compile time

i hope the situation is clear now :)

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

I don't really understand the problem.

By "template" do you mean your custom control in its default
state
when
it's
first added to a Form?

Are the disappearing controls disappearing in the designer, at
runtime
or
both?

Are you adding the disappearing controls to your custom control
in
its
constructor or upon some event such as Load? Are they even
being
added
by
the custom control itself?

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@51g2000cwl.googlegr oups.com...
Hello

i have now removed panel from my custom control. The control
added
by
drag drop is now becoming the child of my custom control but
When
i
compile the application after dropping a control say text box
on
my
custom control, the controls present on the template of custom
control
disappear.
i have two controls defined in the template, a checkbox and an
image.
There are two picture boxes as the property of the custom
control
too.
The property picture boxes (which i specify at the design
time)
remains
intact while those (check box and picture box) which are the
part
of
template disappear.

I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong
now?

Regards
//Rizwan
Dave Sexton wrote:
Hi Rizwan,

To support drag & drap in the designer for your custom
control
you
can
inherit from ContainerControl instead of Control or use the
DesignerAttribute as you have illustrated.

However, you won't be able to drag & drop controls into a
Panel
that
is
within your control. Drag & drop support doesn't go that
"deep".

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googleg roups.com...
Hello

i have made a custom control. i have placed a panel on it.
I
want
this
panel to behave just like the normal panel. The problem i
was
having
is
that the panel on my custom control doesnt accept other
controls.
The
control i drag drop on it becomes the child of my custom
control's
parent form and not the child of my custom control. Then i
added
this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line
does).
Now
when i drag drop a control (say text box) onto the panel of
my
custom
control, the newly added control goes behind the custom
control.
It
becomes the child of my Custom control but i am unable to
bring
it
to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that
accepts
other
control on design time (through drag drop) and behaves like
ordinary
user control.

Regards
Rizwan



Jan 10 '07 #15

P: n/a
Hi,

I tried a bunch of things with your source code but I can't reproduce the
problem, not even with resizing the control as you've suggested. It's
strange since your code derives from ContainerControl, as I originally
suggested, and it seems to work just fine but it didn't work when I tested
it with an even simpler program (just the control and a TextBox). I tried
adding a control to your user control in the Form from the toolbox, dragging
the button into your control, resizing it in all different directions,
closing and reopening the Form designer and closing and reopening the
UserControl designer. I also tried deriving from Panel, which worked for me
in my testing and worked in your program as well.

It seems like a designer bug to me, especially because this behavior is
unpredictable. You may want to file a bug report with Microsoft. Do some
research to make sure it's not already submitted first:

https://connect.microsoft.com/site/s...1.0&siteid=210

For now, try coding it without designer support and see if that helps.

GL

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11*********************@38g2000cwa.googlegrou ps.com...
Hi

download 'short complete' program from here
http://download.yousendit.com/09615D3C279284F9

thanks
//Rizwan

Dave Sexton wrote:
>Hi,

I was able to reproduce the problem:

1. Create a UserControl
2. Add a CheckBox
3. Change the class to derive from ContainerControl in code
4. Build.
5. Create a Form
6. Add the custom control to the Form
7. Add a TextBox to the custom control in the Form designer
8. Build and run.

Controls defined in the custom control disappear at runtime and in the
designer; however, controls added to the custom conrol in the Form
persist.

This behavior appears to be the fault of the ContainerControl's designer.
A
workaround is to derive your control from Panel instead.

HTH

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@q40g2000cwq.googleg roups.com...
Hi Dave

Ok it seems like i know the problem now :) but not the solution. I am
going to re write the problem in relation to 'short but complete
program' that i have created. Code is appended at the end.

I have a custom control, which contains only one default control i.e.
check box. This checkbox is added into the template of custom control
and act as default control of my custom control. The checkbox is placed
to top right corner of custom control and is anchor is set to top right
corner too.

I add my custom control to a form and compile it. Now i resize (making
it smaller) from the top right corner towards centre. As the anchor of
the checkbox is set to top right, therefore it moves with the top right
corner. I compile the program. The custom box is now displayed smaller
in size with checkbox attached to top right corner. Everything is fine.

Now i repeat the same procedure after placing a control say Button from
toolbox on my custom control. When i am resizing the custom control
(making it smaller, moving from top right corner to centre) the
checkbox moves with the top right corner. Everything looks fine before
compiling. But when i compile the application, the checkbox is gone
(not displayed). I think it looses its anchor. when i again resize the
custom control (making it bigger enough to be at least of original size
by dragging the top right corner to the angle of 45 degree) the
checkbox is dispalyed again. Same happens with all default controls of
custom box.

My question now is that, why the toolbox control make default controls
of custom control loose their anchor? or is this really the anchor
problem or something else...

i am placing the code of two classes. i dont know whether this code is
enough or not.

///////////////////////////////////////
namespace tempPrj
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
///////////////////////////////////////

///////////////////////////////////////
namespace tempPrj
{
public partial class UserControl2 : ContainerControl
{
public UserControl2()
{
InitializeComponent();
checkBox1.Checked = true;
}
}
}
///////////////////////////////////////

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

At this point I doubt anyone will be able to help you without seeing
some
simple code that reproduces the issue you are having. I can keep
guessing,
but we probably won't get anywhere with it :)

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11*********************@51g2000cwl.googlegro ups.com...
Hi Dave

yes you are right, i shouldnt have created new thread.

i read ur reply in new thread. i created simple application to
replicate the error. what i found now is the hiding of controls is
because of the change in size of custom control.

i try to make clear what is the problem now.

I place my custom control over the form. i compile it, everything
works
fine. i resize my custom control (make it smaller), recompile it.
everything works fine.

now here comes the problem. I place my custom control over the form.
i
compile it, everything works fine. i resize my custom control (make
it
smaller), place control from toolbox over my custom control,
recompile
it. The checkbox and image (which i mentioned in earlier posts)
become
hidden (they are not deleted, they become hidden).

Now i am wondering what the control from toolbox does to my custom
control. The resizing (making smaller in size) works fine without
adding the control from toolbox.

Regards
//Rizwan

Dave Sexton wrote:
Hi Rizwan,

I'm curious to know whether the controls are being removed or
simply
hidden.

You may want to post some code as I mentioned in your other thread
otherwise
it's going to be difficult, if not impossible, to help.

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googleg roups.com...
Hi Dave

lot of thanks for replying.

by template control i mean the controls which are added in its
default
state, for example , the maximize minimze image, It is there in
the
default state, and user can not change it in design time.

Disappearing controls: The controls (only default controls)
disappear
when i compile the application. When i add my custom control to a
form,
every thing is fine. i compiel the code, works fine. when i add
control from toolbar by drag drop, everything works fine. But as
soon
as i compile the application (after adding control from toolbar),
the
controls (only default controls) disappear. And ofcourse when i
run
the
application they are not visible too.

i have two default controls on custom control, one is check box
and
other is picture box. I add these controls during the desiging of
the
custom control (not the design time of form). I set the picture
for
picture control and check the checkbox in the constructor of the
custom
control. After building the code, my custom control is ready for
use
with two default controls on it. Please note that there is also a
group
box used as line seperator (it is also a default control). but
this
group box doesnt disappear. on compile time

i hope the situation is clear now :)

Regards
Rizwan

Dave Sexton wrote:
Hi Rizwan,

I don't really understand the problem.

By "template" do you mean your custom control in its default
state
when
it's
first added to a Form?

Are the disappearing controls disappearing in the designer, at
runtime
or
both?

Are you adding the disappearing controls to your custom control
in
its
constructor or upon some event such as Load? Are they even
being
added
by
the custom control itself?

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@51g2000cwl.googlegr oups.com...
Hello

i have now removed panel from my custom control. The control
added
by
drag drop is now becoming the child of my custom control but
When
i
compile the application after dropping a control say text box
on
my
custom control, the controls present on the template of custom
control
disappear.
i have two controls defined in the template, a checkbox and an
image.
There are two picture boxes as the property of the custom
control
too.
The property picture boxes (which i specify at the design
time)
remains
intact while those (check box and picture box) which are the
part
of
template disappear.

I have tried by setting designer property and inheriting from
ContainerControl, same problem with both. what is going wrong
now?

Regards
//Rizwan
Dave Sexton wrote:
Hi Rizwan,

To support drag & drap in the designer for your custom
control
you
can
inherit from ContainerControl instead of Control or use the
DesignerAttribute as you have illustrated.

However, you won't be able to drag & drop controls into a
Panel
that
is
within your control. Drag & drop support doesn't go that
"deep".

--
Dave Sexton
http://davesexton.com/blog

<ri***********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googleg roups.com...
Hello

i have made a custom control. i have placed a panel on it.
I
want
this
panel to behave just like the normal panel. The problem i
was
having
is
that the panel on my custom control doesnt accept other
controls.
The
control i drag drop on it becomes the child of my custom
control's
parent form and not the child of my custom control. Then i
added
this
line
"[Designer("System.Windows.Forms.Design.ParentContro lDesigner,System.Windows.Forms.Design")]"
before my custom control class (i dont know what this line
does).
Now
when i drag drop a control (say text box) onto the panel of
my
custom
control, the newly added control goes behind the custom
control.
It
becomes the child of my Custom control but i am unable to
bring
it
to
front. Also my custom control becomes distorted.

To summarize all. I want to have a custom control that
accepts
other
control on design time (through drag drop) and behaves like
ordinary
user control.

Regards
Rizwan



Jan 10 '07 #16

This discussion thread is closed

Replies have been disabled for this discussion.