471,627 Members | 1,683 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.

Designer Serialization Issues

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 19 '06 #1
1 1907
Hi all,

Since nobody has yet responded to my cry for help, here's some more info
that might help assist me (or assist helping me?):

Closing the designer window in between complications and runs, does seem to
solve the problem over the ever-decreasing size, but I still have an initial
sizing problem.

To explain this further:
I initially set the size of the control (actually, it’s a few controls) to
fit the width of the form in the designer. I close and save the control. I
run the application. The width of the controls is as it should be. I exit
the application and re-open the form in the designer. The controls have
reverted back to a size almost half the width of the form!

I have checked the code to look at what I do with the size of the controls.
One (and only one) of the user controls on the form is adjusting its size
depending on certain conditions in the Resize event, which I presume will be
triggered when the size of the control or form on which the control is
“dropped” changes. This does not fit what I see anyway and does not explain
why the other controls don’t behave properly.

Perhaps a bit more detail is required. This is the “hierarchy” of form and
controls:

Form
|_ SplitContainer
|_ Panel1
|_ Panel2
|_SplitContainer
|_Panel1
|_TabControl
|_TabPage1
|_UserControl1
|_UserControl2
|_Standard Control

All the controls on the lowest level (inside TabPage1) suffer from the same
sizing problem.
Could it be it’s just getting too complicated for the designer because I
have multiple layers of controls and it involves two SplitContainers?

Just a thought…

Lucien.
"Lucien Dol" <lu********@xtra.co.nz> wrote in message
news:qC**********************@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 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Aaron Clamage | last post: by
11 posts views Thread by Daniel Billingsley | last post: by
reply views Thread by Adam Right | last post: by
1 post views Thread by =?Utf-8?B?RjVGNUY1?= | last post: by
6 posts views Thread by =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post: by
1 post views Thread by XIAOLAOHU | 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.