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
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
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
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
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.ParentControlDesigner,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