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

Home Posts Topics Members FAQ

resizing form in constructor

In my forms constructor I have the following:

this.WindowState = FormWindowState.Maximized;

I then try to size some controls based on the size of the maximized form's
client area:

SomeControl.Height = (this.ClientSize).Height;

But this never returns the proper value i.e. (this.ClientSize).Height is
always too small (around 230 pixels). What is going wrong?
Nov 17 '05 #1
3 2156
size the controls in the Resize() event not the form load or
constructor.

--
Robbe Morris - 2004/2005 Microsoft MVP C#
Free Source Code for ADO.NET Object Mapper To DataBase Tables And Stored
Procedures
http://www.eggheadcafe.com/articles/..._generator.asp


"Lionel" <Li****@discussions.microsoft.com> wrote in message
news:19**********************************@microsof t.com...
In my forms constructor I have the following:

this.WindowState = FormWindowState.Maximized;

I then try to size some controls based on the size of the maximized form's
client area:

SomeControl.Height = (this.ClientSize).Height;

But this never returns the proper value i.e. (this.ClientSize).Height is
always too small (around 230 pixels). What is going wrong?

Nov 17 '05 #2


"Lionel" wrote:
In my forms constructor I have the following:

this.WindowState = FormWindowState.Maximized;

I then try to size some controls based on the size of the maximized form's
client area:

SomeControl.Height = (this.ClientSize).Height;

But this never returns the proper value i.e. (this.ClientSize).Height is
always too small (around 230 pixels). What is going wrong?

Hi,
After the intializecomponents() function only each control height and width
value will assign
try
form_load event other wise try after form.show() function call the same
code

Regards
sambath R
Nov 17 '05 #3
Hi Lionel,

Control class provides event Layout that is meant to be used exactly in this
scenarios. The event is fired whenever a control needs to reposition its
children elements.

In your form you can handle this event overriding the OnLayout method. Don't
forget to call the base class in order the form to fire the event so other
interested parts can have chance to process it.

HTH
--
Stoitcho Goutsev (100) [C# MVP]

"Lionel" <Li****@discussions.microsoft.com> wrote in message
news:19**********************************@microsof t.com...
In my forms constructor I have the following:

this.WindowState = FormWindowState.Maximized;

I then try to size some controls based on the size of the maximized form's
client area:

SomeControl.Height = (this.ClientSize).Height;

But this never returns the proper value i.e. (this.ClientSize).Height is
always too small (around 230 pixels). What is going wrong?

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: TJ Talluto | last post by:
<facts> I have a "month calendar" that always displays exactly 42 days... and alongside is a vertical box that displays the detail (form fields) of any particular select event that appears on the...
0
by: Tony | last post by:
Derived Forms resizing in dotnet. (Fix) Problem: If you have a form base class: public frmBase : System.Windows.Forms { public frmBase { // DefaultFormFont is new Font("Tahoma", 10);
1
by: Terry | last post by:
I've seen several posts from people who have seen this flashing in TreeView's when resizing a form. I've noticed it in my app, but only in the child windows. For example, my main form has a...
12
by: Søren Reinke | last post by:
Hi there I have a little problem. How do i make sure that a graph is not redrawn while the form with the graph is being resized ? I have tried to add a mouse up/down event handler on the...
6
by: John Bowman | last post by:
Hi All, I must be missing something really obvious, so I'd appreciate someone helping me out. I have a simple Windows form that currently only has a title bar (aka the Text Property is set) and...
11
by: Sharon | last post by:
I'm writing a new control derived from UserControl. I need to get an event when the control is done resizing. I tried the Resize, SizeChanged, Move and the Layout events and I also tried to...
2
by: Nathan | last post by:
How doy you resize the background image to fill a form when the form is resized?
6
by: JDeats | last post by:
I have a WinForms based application written for the .NET Framework 2.0 and in this application I need to be able to be able to take some action in code when the user finishes resizing the form. ...
10
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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.