473,480 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to make custom control act like container for other controls

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
15 6464
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2202
by: Juan Romero | last post by:
Hey guys, I am working on a web custom control that basically draws a table (ASP Table) with a few child controls in the cells. I have a command button inside one of these cells. The problem I...
7
3323
by: Girish | last post by:
OK.. phew. Playing with data grids for the past few days has been fun and a huge learning experience.. My problem. I have a requirement to display a gird with a gird. Within the embedded grid,...
9
4669
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate>...
7
3306
by: aviad | last post by:
I am writing a Form application I need it to fit both resolution of 1600*1200 and 800*600 (and any other resolution that might jump in) the application is meant for regular PCs another question...
0
1541
by: LaptopHeaven | last post by:
I am having some trouble. How would one load a custom UserControl fro within a class which impements the ITemplate interface. Currently I have the following: public class...
11
3252
by: Nick Gilbert | last post by:
Hi, How can I create a custom control which will wrap its content in a header and footer? eg: Is it possible to create a .NET user control which can surround other controls? eg:...
1
2220
by: mnuckols | last post by:
I am trying to create a custom container control for Windows Forms using C#.NET 2.0. My problem is that I want only part of the control to allow other controls to be placed on it at design time. ...
4
2461
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
16
3971
by: pupilstuff | last post by:
hi guys i just want to perform custom paging in which at the footer of the grid view ,there must be a pager 'pervious/next with numeric' this is what i did in aspx page <asp:GridView...
0
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7037
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7080
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5326
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4476
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1296
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
176
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.