Click here to Skip to main content
15,860,859 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 .

C#
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
Updated 6-Apr-13 4:10am
v2
Comments
Kenneth Haugland 6-Apr-13 10:10am    
I assumed WinForms so I updated the Tag.
Neetesh Agarwal 6-Apr-13 10:13am    
Thanks a lot Sir.

1 solution

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)
 
Share this answer
 
Comments
Neetesh Agarwal 6-Apr-13 10:13am    
Thanks Sir..........
OriginalGriff 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900