473,320 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 1908
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jason Winters | last post by:
I have implemented a user control in c# .net 2002 but the problem is that the control keeps disappearing off of the form for no reason. I am not making any changing to the form or the control. It...
19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
17
by: Lloyd Sheen | last post by:
This IDE is driving me nuts. I needed another button so I copied an existing one, changed the Text and the id and position by drag and drop. Well then I run and get the following: Control...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
1
by: Kris van der Mast | last post by:
Hi, been a while since I posted a question myself instead of trying to help others out. I'm refactoring an existing web app that uses dynamic loading of user controls and a lot of...
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
4
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
0
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
5
by: ross kerr | last post by:
Hi All, I am extending the combobox to create a control that selects an item based on the text the user is typing into the text area of the control. I have an issue that occurs only when i...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.