Author Topic: UserControl with DataGridViews in SplitContainer layout issue  (Read 1494 times)

0 Members and 1 Guest are viewing this topic.

Atook

  • Swamp Rat
  • Posts: 1029
  • AKA Tim
UserControl with DataGridViews in SplitContainer layout issue
« on: January 21, 2017, 01:26:55 PM »
I've got two DataGridViews embedded in different panels on a SplitContainer. They look good at design time and behave as I expect when I resize the control in visual studio.

But at runtime the palette doesn't look right, the DGV drops below the Total Demand labels

Both DGVs have anchors set to left,right, top, bottom. It almost looks as if the DGVs are getting anchored to the bottom of the palette instead of the bottom of their respective panels in the SplitContainer.

Any ideas for what I'm doing wrong, or solutions to the problem? I'm contemplating removing the Total Demand fields out of the SplitContainer, but I think that's where they belong.

Atook

  • Swamp Rat
  • Posts: 1029
  • AKA Tim
Re: UserControl with DataGridViews in SplitContainer layout issue
« Reply #1 on: January 21, 2017, 08:14:37 PM »
Found a workable solution: I created a panel for the controls above the DGV and a panel for the controls below it. Set the dock for the top panel to top, and the dock for the bottom panel to bottom, with the DGV.dock set to fill. The order the controls are added makes a difference in how it all works and it took me a while to figure that out. Using Views->Other Windows-> Document Outline  allowed me to change the order of the top/bottom panels and the DGV to achieve the correct result.