471,627 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Problems with user control in designer

Hi all,

Can someone help me with this, please?

I've got a user control that (amongst other controls) contains a textbox.
The textbox has its Anchor property set to "Left, Top, Right", meaning that
it will stretch automatically when the control is resized on a form or other
user control. When in design mode I look at the control by itself (rather
than dropped on a form) the control has a certain size (let's call this
SizeA).

This user control is dropped on another user control that is dropped onto a
form that is slightly wider. I set all the Anchor and Dock properties so
that the controls neatly fill the forms.
When I run the application all works fine and the controls sizes as it
should when required.

On closing the application the user control (when looking at the form it's
on) has shrunk and now has a different size (SizeB), while when I look at
the control in its own designer window it still has the original size.

If I run the application again (without correcting the control's size) the
control now starts with the smaller size (i.e. no longer fills the width of
the form) even though it will still stretch when I resize the form.
Exit the application again and - voila! - the control is even smaller
(SizeC)!

When I look at the Control.Designer.cs file in between runs I can see that
the Windows forms generator changes the Size property between each run of
the application.

Why does this happen and how can I fix it? Does it have something to do with
the designer serialization? If so, how do I add a
DesignerSerializationAttribute to the textbox or the control itself in such
a way that it retains its correct size? And can I do this interactively
somehow or do I need to overwrite some properties in code? Or is there
another way?

Any help is appreciated.

Lucien Dol.

Feb 17 '06 #1
1 1811
Just bumping this message... Still had no replies... :-(

"Lucien Dol" <lu********@xtra.co.nz> wrote in message
news:ms**********************@news.xtra.co.nz...
Hi all,

Can someone help me with this, please?

I've got a user control that (amongst other controls) contains a textbox.
The textbox has its Anchor property set to "Left, Top, Right", meaning
that it will stretch automatically when the control is resized on a form
or other user control. When in design mode I look at the control by itself
(rather than dropped on a form) the control has a certain size (let's call
this SizeA).

This user control is dropped on another user control that is dropped onto
a form that is slightly wider. I set all the Anchor and Dock properties so
that the controls neatly fill the forms.
When I run the application all works fine and the controls sizes as it
should when required.

On closing the application the user control (when looking at the form it's
on) has shrunk and now has a different size (SizeB), while when I look at
the control in its own designer window it still has the original size.

If I run the application again (without correcting the control's size) the
control now starts with the smaller size (i.e. no longer fills the width
of the form) even though it will still stretch when I resize the form.
Exit the application again and - voila! - the control is even smaller
(SizeC)!

When I look at the Control.Designer.cs file in between runs I can see that
the Windows forms generator changes the Size property between each run of
the application.

Why does this happen and how can I fix it? Does it have something to do
with the designer serialization? If so, how do I add a
DesignerSerializationAttribute to the textbox or the control itself in
such a way that it retains its correct size? And can I do this
interactively somehow or do I need to overwrite some properties in code?
Or is there another way?

Any help is appreciated.

Lucien Dol.

Feb 18 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Jason Winters | last post: by
17 posts views Thread by Lloyd Sheen | last post: by
1 post views Thread by Kris van der Mast | last post: by
4 posts views Thread by Tim::.. | last post: by
reply views Thread by Tim::.. | last post: by
5 posts views Thread by ross kerr | last post: by
reply views Thread by leo001 | last post: by

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.