0

I have mdiparent form which has menu and a panel on the left which includes treeview. the remaining space of the parent form can include multiple windows depending on the user how many he wants to open it. There is a splitter in the edge of the panel[ the one with treeview, on the left] which can increase or decrease the width of the panel and thereby increasing the area for the chart.

I have tried using the mdilayout in splitter move event handler, but it does not work. The red vertical line is the splitter to increase/decrease the width of the panel on the left. Initially, there is no space on the right side . opening a new child window fits well in the remaining space.

Splitter moved to the left. There is a space in the right, child form does not resize and fit to the areaSplitter moved more to the left and space on the right keeps increasing. If I open one more graph then 4 old and 1 new , total 5 forms fill perfectly fit well and space will be utilized. if I move the splitter again then space on the right side will be introduced again.

How can I make all the child forms to exactly fit the remaining space, each time the splitter moves?

Code in Splitter move/mouseup event handler.

    this.LayoutMdi(MdiLayout.TileHorizontal);       

Child Forms [ the graph windows] have

    this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;

Parent Form [ which is in the picture]

    this.leftpanel.Dock = System.Windows.Forms.DockStyle.Left;
    this.leftpanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    this.AutoSize = true;

If parent form is resized then resize event handler is also

    this.LayoutMdi(MdiLayout.TileHorizontal);

which seems to work well. if I maximize / custom size parent form, child forms resize accordingly .

if I use same thing for , splitter eventhandlers, it does not work in the same way.

Thanks,

Charlotte
  • 111
  • 1
  • 9
saumil patel
  • 247
  • 5
  • 16
  • I'd guess that the faster you move the splitter, the more space you'd get. Something wrong with your code, we can't see it. – Hans Passant Jun 12 '13 at 13:28
  • I have edited the post ! yes, the faster I move, the more space I get. if I move it slowly, I will get less space. It is a random behavior I believe or I don't understand the logic of why fast and slow will behave differently. – saumil patel Jun 13 '13 at 09:04

1 Answers1

0

Tried something like this?

Form.Anchor = AnchorStyles.Left | AnchorStyles.Top;
Nick Garfitt
  • 35
  • 1
  • 9
  • Sorry then :/ no clue Are you using a SplitContainerControl or a Splitter – Nick Garfitt Jun 12 '13 at 09:35
  • just a splitter,I could ve used a SplitContainerControl.It can serve the purpose. But for that I will have to add all the child forms in the panel. It can cause a performance issue in my application. Since , I don't know how many child windows a panel will be able to handle. – saumil patel Jun 12 '13 at 09:54
  • Well to be honest it's worth a shot at least :) – Nick Garfitt Jun 12 '13 at 10:08
  • It doesn't work. I tried it. I referred http://stackoverflow.com/questions/4230486/splitcontainers-panel-as-the-mdi-parent-for-other-forms and http://stackoverflow.com/questions/4571843/panel-and-mdi-in-c-sharp/4571863#4571863 – saumil patel Jun 12 '13 at 10:41
  • yes , unfortunately it did not work. layout logic works fine in form resize event handler. it should work in the splitter event handler. so frustrating ! – saumil patel Jun 13 '13 at 09:05