Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# .NET WinForm
Hello friends,
 
I am working in a window Application. There is two group box in form and each group box has a grid view. My need is when I click on Maximum button of form then Both Group box and control inside group box should also increases and fit in form equally without no gap.
But when I am maximize the size it increases group box but there is a gap between two .
 
private void Form1_Resize(object sender, EventArgs e)
       {
           if (this.MaximizeBox)
           {
 
               groupBox1.Dock = DockStyle.Left;
               groupBox2.Dock = DockStyle.Right;
           }
       }
 

Please tell me how to solve this?
 

Thanks in Advance
Neetesh
Posted 6-Apr-13 4:48am
Edited 6-Apr-13 5:10am
v2
Comments
Kenneth Haugland at 6-Apr-13 10:10am
   
I assumed WinForms so I updated the Tag.
Neetesh Agarwal at 6-Apr-13 10:13am
   
Thanks a lot Sir.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Instead of using Dock left and Dock right, fill your form with a Splitter, and dock each control in a panel each side.
Reduce the SplitterWidth property to 1, and set IsSplitterFixed to true.
Then handle the Splitter.Resize Event and set the SplitterDistance to half the width. (You will also want to do this in the form Load or Shown event as well.
It will work a lot better than docking left or right, which expects a centre area for other controls.
 
(You can also do this by setting the controls in place manually in the designer and setting the Anchor properties correctly, but that gets kinda messy to work out with more than two controls)
  Permalink  
Comments
Neetesh Agarwal at 6-Apr-13 10:13am
   
Thanks Sir..........
OriginalGriff at 6-Apr-13 10:32am
   
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 299
1 Maciej Los 295
2 Sergey Alexandrovich Kryukov 230
3 Aajmot Sk 191
4 Sinisa Hajnal 166
0 OriginalGriff 7,760
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,785


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 6 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100