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

Anchoring and docking (problem with sizable form)

Hi!

I have a window form that contains 4 elements (2x2) on one panel.
Those 4 elements are GroupBoxes of the exact same size, sorted like this:
groupBox1 groupBox2
groupBox3 groupBox4

While resizing a Form window manually, I would like to resize
automatically each groupBox by keeping the same ratio:
Width of each groupBox = 50% of Panel-width
Height of each groupBox = 50% of Panel-height
I'm playing with applying different values to Anchor properties, but
still can't make it right.

Example:
--
this.groupBox1.Anchor = ((AnchorStyles)((((AnchorStyles.Top |
AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
--
Nov 16 '05 #1
3 12219
BTW, that panel has a Dock property:
this.panel1.Dock = DockStyle.Fill;

Illustration of what I'm trying to do is here:
===
*http://www.pou-kop.hr/test/sizable.html
Nov 16 '05 #2
The only way to do this with the current version of WinForms under .NET
is to get rid of the anchoring, etc. on the GroupBoxes, react to the
Panel.Resize event and resize the group boxes in code.

The problem is that the way that panel docking and anchoring works
right now in .NET, you always have to give one panel preference on
resize. You can DockStyle.Left the left-hand panel and DockStyle.Fill
the right-hand panel, which will leave the left panel the same size as
the right on resize, or the reverse. The same goes for top and bottom.
There is no way to tell WinForms (under .NET) to "keep the proportion
the same". (Zeitgeist is a funny thing: a poster in the GotDotNet
message boards was just asking exactly the same question.)

So, your only recourse is to subscribe to the Panel.Resize event and
within your event handler move and resize the group boxes
programmatically. (Make sure to remove any anchoring or docking from
them so that you're not fighting against WinForms in the process.)

I've heard rumours that the v2.0 framework will include some
enhancements to WinForms layout management. I hope so: where layout
management is concerned I found moving from Java to C# a step down. It
would be nice to see it fixed.

Nov 16 '05 #3
Bruce Wood wrote:
So, your only recourse is to subscribe to the Panel.Resize event and
within your event handler move and resize the group boxes
programmatically.
I have VS .NET 2003 and this is a brand new information for me.
Thank you very much, Bruce... I'll do it programmatically then.
I've heard rumours that the v2.0 framework will include some
enhancements to WinForms layout management. I hope so: where layout
management is concerned I found moving from Java to C# a step down. It
would be nice to see it fixed.


I've already found few more bugs in layout management and bugs like this
one: accessing the Text or RichText property of a .NET RichTextBox (even
reading from it) clears the Undo/Redo buffer, so CanUndo and CanRedo
yield false after that!

I really hope that the Framework v2.0 will fix all of this stupidities!

Have a nice day! :)
Nov 16 '05 #4

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

Similar topics

12
by: Tom | last post by:
Hi all, I am a newbe to javascript so I could use your help. I checked the FAQs and searched google but I could not resolve this problem. My form is as follows: <form...
1
by: Vinnie Murdico | last post by:
Hi, We have an order form on our site that is a simple HTML page that has a FORM in it. The FORM ACTION is to run a perl script that processes the order. For a long time, we've noticed on...
1
by: Dayne | last post by:
I have a problem with how visual studio.net's form designer handles form inheritance. This is what I am trying to do.. I have a base form with some controls on it..I then create a child Form from...
0
by: ka | last post by:
I'm using Corwnwood.Magic library for docking in my application. My application to let the users to create their screen look to show some particular data. I treid to dock my things in the way,...
1
by: juli jul | last post by:
Hello, I need to place those controls in the form in the order that I am writing: 1)ListView (aligned dock to "Fill") 2)Spliter aligned to left(dock=left). 3)TreeView aligned to...
1
by: Ahmed | last post by:
Hello everyone, I am designing an application to work with two screen resolutions, 1024x 768 and 800x600. If the user is using a higher resolution the form should have the same size as 1024x768...
0
by: daveryan78 | last post by:
Hi all, I've been getting a strange problem with anchoring on my forms. I have a form where I put on a tabControl. I set it's anchoring to Top, Bottom, Left, Right. I put a number of tabPages on...
1
by: marciojersey | last post by:
Hi everyone. I'm having a problem with form opacity in my c# application. I have a window with a vrml viewer com control and whenever the window goes into layered mode, the vrml viewer is rendered...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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...

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.