473,378 Members | 1,492 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,378 software developers and data experts.

Correct way to resize a control when form is resized

Is this the correct way to resize the controls on a form when the form
is resized?

protected override void OnResize(EventArgs ea)
{
listViewFiles.Width= this.ClientSize.Width-5;
lisInfoList.Width=this.ClientSize.Width-5;
}

What about buttons and other controls? Any links are appreciated.

Nov 17 '05 #1
8 2239
You might want to check out the Anchor property on the control. If you
set it, you can say "this side will expand when the container it is hosted
in expands". It saves you from having to write all that messy code
yourself.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ne***********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Is this the correct way to resize the controls on a form when the form
is resized?

protected override void OnResize(EventArgs ea)
{
listViewFiles.Width= this.ClientSize.Width-5;
lisInfoList.Width=this.ClientSize.Width-5;
}

What about buttons and other controls? Any links are appreciated.

Nov 17 '05 #2
Have you checked into the Dock and Anchor properties of the controls in
question? Unless you require non-standard behavior, these properties
make it very easy to handle resizing.

Nov 17 '05 #3
Is it not possible to just use Anchoring?

<ne***********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Is this the correct way to resize the controls on a form when the form
is resized?

protected override void OnResize(EventArgs ea)
{
listViewFiles.Width= this.ClientSize.Width-5;
lisInfoList.Width=this.ClientSize.Width-5;
}

What about buttons and other controls? Any links are appreciated.

Nov 17 '05 #4
I found them and got some of the items to work, but when, for example,
I maximize my window the buttons get huge for some reason. The
listview and listbox I have resized fine. thanks.

Nov 17 '05 #5
It is. I"m sorry guys. I should have found that one myself. I got
it. Thanks again.

Nov 17 '05 #6
Don't worry about it. I sometimes get stumped for days on something that is
blatently obvious.
If one of us writing just a line of two of text saves you hours then thats a
good thing. :)

Jax

<ne***********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
It is. I"m sorry guys. I should have found that one myself. I got
it. Thanks again.

Nov 17 '05 #7

needin4mat...@gmail.com wrote:
I found them and got some of the items to work, but when, for example,
I maximize my window the buttons get huge for some reason. The
listview and listbox I have resized fine. thanks.


You probably have your buttons anchored on all four sides. Normally,
you only want buttons anchored to the top left or bottom right.

Nov 17 '05 #8


"Chris Dunaway" wrote:
Have you checked into the Dock and Anchor properties of the controls in
question? Unless you require non-standard behavior, these properties
make it very easy to handle resizing.


True as long as you don't need anything truely fancy. OTOH in my current
app there was an instance where resizing manually resulted in significantly
less flickering. The affected control is a multiline textbox inside a
manually resized groupbox.

If you have to do manual work plan on taking enough time to test multiple
approaches for each change, even though the code on your end is almost the
same the speed of what's being done by the framework might not be. In some
cases what looks like it should be the faster way might not be. IN my case
setting the Size property was faster than setting the width only and letting
anchoring handle the vertical sizing.
Nov 17 '05 #9

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

Similar topics

3
by: Paul Jaeger | last post by:
I have jpeg images that are 2848 x 4256 pixels. I want to programatically convert them to images that are approximately 427 x 638 (that maintains the ratio) and save to new jpeg files. How can...
0
by: Dave Veeneman | last post by:
I'm creating a custom control that uses the OnPaint event to paint a graphic. The graphic needs to resize itself when the control is resized. Right now, I'm trapping the Resize event to trigger the...
3
by: Z D | last post by:
Hello, BACKGROUND: ============== I've created a Windows User Control that contains an Image Control (among other controls). The user control handles the picture resize event. Whenever the...
4
by: Rob Richardson | last post by:
Greetings! I have a form with a listview, a menu, and a few text boxes, labels and command buttons. I want to resize the listview when the form is resized to that the widths of the spaces...
3
by: BrianDH | last post by:
Hi I have a windows form and with init I have a tab control. How can I get the tab control to resize, Min/Max as the windows form is resized? Thanks
1
by: Rich | last post by:
Hello, I have a child form in a parent MDI form. The childform is being shrunk and cannot be resized when screen resolution is 800x600. The end user who uses my app cannot see stuff on the...
8
by: nirdeshonline | last post by:
Hi, I have added a simple listbox in windows form under c# 2.0. It contains a collection of approx 10 strings as list items. Now when i resize the form whole listbox flickers. Please tell me...
11
by: Ajith Menon | last post by:
I have created a windows application in which the form needs to be resized on the MouseMove event. The windows resize function takes a lot of CPU cycles. And as the resize function is called on the...
4
by: michael sorens | last post by:
In a Windows Form application, when a user resizes the window, I typically want different components in the form to take different actions. For example, a text box in the middle should grow...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.