splitContainer splitterdistance set before size in designer
-
I use VS2008. I have a [horizontally] splitContainer, in the designer its width is set to 924px, The splitter distance to 462px and both panels have their minimum width set to 370. So far so good, when I built I got an error, along the lines of "The spliter distance must be set between the minium width of Panel1 and the container width - minimum width of container 2" (not those exact words). In my book that means the splitter distance of 462 must be between 370 and (924 - 370 = 554) which, unless arithmatic or the fundamental nature of maths has changed since I was a boy, it is. The problem is that in the Designer.cs class this code
this.splitContainerMain.Size = new System.Drawing.Size(924, 496);
comes after
this.splitContainerMain.Panel1.Controls.Add(this.groupBoxUnrecognised);
this.splitContainerMain.Panel1MinSize = 370;
//
// splitContainerMain.Panel2
//
this.splitContainerMain.Panel2.Controls.Add(this.splitContainerDone);
this.splitContainerMain.Panel2MinSize = 370;and
splitContainerMain
uses a default width of 150px, breaking the calculation. Is there any way to fix this problem permanently?CCC solved so far: 2 (including a Hard One!) 37!?!! - Randall, Clerks
-
I use VS2008. I have a [horizontally] splitContainer, in the designer its width is set to 924px, The splitter distance to 462px and both panels have their minimum width set to 370. So far so good, when I built I got an error, along the lines of "The spliter distance must be set between the minium width of Panel1 and the container width - minimum width of container 2" (not those exact words). In my book that means the splitter distance of 462 must be between 370 and (924 - 370 = 554) which, unless arithmatic or the fundamental nature of maths has changed since I was a boy, it is. The problem is that in the Designer.cs class this code
this.splitContainerMain.Size = new System.Drawing.Size(924, 496);
comes after
this.splitContainerMain.Panel1.Controls.Add(this.groupBoxUnrecognised);
this.splitContainerMain.Panel1MinSize = 370;
//
// splitContainerMain.Panel2
//
this.splitContainerMain.Panel2.Controls.Add(this.splitContainerDone);
this.splitContainerMain.Panel2MinSize = 370;and
splitContainerMain
uses a default width of 150px, breaking the calculation. Is there any way to fix this problem permanently?CCC solved so far: 2 (including a Hard One!) 37!?!! - Randall, Clerks
OK this is a bit schitzo, answering my own question, but I've found the magic google search term and go a word around here from here http://social.msdn.microsoft.com/forums/en-US/winformsdesigner/thread/ee6abc76-f35a-41a4-a1ff-5be942ae3425/[^] In the parent form, hook into the
Load
event and set theMinSize
property there, not in the designer. The obvious option (moving the code in the designer.cs file) is repeatedly overwritten if the form is re-worked (in my case just setting the tab order did this) and is not viable long term. Pretty bad design work from Microsoft IMO!CCC solved so far: 2 (including a Hard One!) 37!?!! - Randall, Clerks