0
votes

I seem to have a lot of trouble getting a SplitContainer adjusted the way I like it. I have the following form called frmMain:

frmMain Screenshot

In the form Load code I have to following code:

With MainContainer
    .IsSplitterFixed = True
    .Dock = DockStyle.Fill
    .SplitterDistance = 200
    .FixedPanel = FixedPanel.Panel1
    .Panel1.BackgroundImage = Resources.My.Resources.ResourceFile._001
    .Panel2.BackColor = Color.White
    .Panel2.AutoScroll = True
End With

When I run the code I get the following:

frmMain (Compiled)

I want to remove the gray splitter since there is no use to it. Is this a common beauty bug and is it possible to remove it?

My second problem with the SplitContainer is if I resize my window, the backgroundImage in Panel1 and the white color in Panel2 don't adjust with the window. I searched high and low to the Resize code but I can't find it. The Panel2 has User Controls, eg. Dashboard and are loaded this way: MainContainer.Panel2.Controls.Add(Dashboard).

Is it also possible that Panel2 automatically adjusts to the weidht of the window so thay you only have a hortizontal scrollbar?

Thank you for reading my question and hopefully you can help me solve my problems with the SplitContainer. Have a nice day.

2

2 Answers

2
votes

I want to remove the gray splitter since there is no use to it. Is this a common beauty bug and is it possible to remove it?

If you don't want the user to see or move the splitter, why use a split container? As an alternative, consider using a TableLayoutPanel configured with 1 row and 2 columns. The first column would be an absolute 200 px wide while the second column would be set to 100% wide. In each of the two cells, you could place a panel which is docked and set to have a margin of 0,0,0,0.

My second problem with the SplitContainer is if I resize my window, the backgroundImage in Panel1 and the white color in Panel2 don't adjust with the window. ... Is it also possible that Panel2 automatically adjusts to the weidht of the window so thay you only have a hortizontal scrollbar?

While I did not mock up your current solution, I was not able to replicate these problems with a quick mock up of the solution I proposed above. With regards to auto-scrolling, the only reason that scroll bars should appear would be if a control is off the edge of the screen or the available screen space is less than the minimum size of the panel.

0
votes

You have 2 options:

  • Use TableLayoutPanel (as @erdomke suggests)
  • Use 2 Panel controls

For 2 panel controls, dock panel1 to Left, and dock panel2 to Fill. To fill panel2 with a UserControl that resizes, set it's Dock property also to Fill.