473,809 Members | 2,780 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(EventA rgs ea)
{
listViewFiles.W idth= this.ClientSize .Width-5;
lisInfoList.Wid th=this.ClientS ize.Width-5;
}

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

Nov 17 '05 #1
8 2264
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.co m

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

protected override void OnResize(EventA rgs ea)
{
listViewFiles.W idth= this.ClientSize .Width-5;
lisInfoList.Wid th=this.ClientS ize.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.goo glegroups.com.. .
Is this the correct way to resize the controls on a form when the form
is resized?

protected override void OnResize(EventA rgs ea)
{
listViewFiles.W idth= this.ClientSize .Width-5;
lisInfoList.Wid th=this.ClientS ize.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.goo glegroups.com.. .
It is. I"m sorry guys. I should have found that one myself. I got
it. Thanks again.

Nov 17 '05 #7

needin4mat...@g mail.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
17179
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 .net accomplish the image resizing? Paul J.
0
1309
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 paint. However, the Resize event appears to fire repeatedly as the control is being resized, which causes the control to repaint repeatedly, chewing up CPU capacity. I'd like to have the control redraw only when the resize is complete, not...
3
3270
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 parent that holds my user control is resized, I resize my image so that it uses the maximum available space. Note: It takes about 2 seconds to regenerate the
4
3492
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 between the borders of the listview and the borders of the form remain constant. I am finding this to be unexpectedly hard. For one thing, I initialized some values in the form's Load event, and I'm doing the control resizing in the form's Resize...
3
16198
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
2734
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 screen too well if the resolution is smaller than 800x600 (why did it have to be my app?) Yes, I know, get a bigger screen - $$. Management is on it - just not right now. The parent form can be resized but not the child form. What is the way...
8
6388
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 any feasible solution, i need to use a checked listbox which also has same flickering problem on resize. Thanks & Regards
11
3478
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 MouseMove, the form is resized around a 30-100 times in one second. This leads to a high CPU utilization and all other application comes to a stand still. The form does not have any controls i.e. buttons, text boxes etc. It is completely...
4
2460
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 with the window; a button panel at the bottom should remain the same height but re-center horizontally; etc. What I have settled on as a technique for managing this is to start witha table container (dock=fill), then by combining rowspans,...
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10387
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7662
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3015
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.