Skip to content

MinimumSize property of DockContent. #63

Closed
TheRealWritz opened this Issue Sep 16, 2012 · 10 comments

3 participants

@TheRealWritz

The MinimumSize property of a DockContent [FloatWindow] is not used by dockpanel. I think it would be better if the size of the float window is set first considering the MinimumSize of the DockContent. The FloatWindow presently can be resized to a smaller size than the MinimumSize which i think should not take place!

Thanks.

@TheRealWritz

I have fixed this problem. But, the DockContent has some problem in the MinimumSize. I set A TreeView to DockFill but the border is covered by the FormBorder [Border of the DockContent]. I used the CustomFloatWindow() example to some extent.

@TheRealWritz

The problem is much more when the Tab of a DockPane is changed. Currently, trying to solve that.

Update:
Sorry for the close and reopen of this issue. I mistakenly pressed the Comment and Close button.

@TheRealWritz TheRealWritz reopened this Sep 18, 2012
@roken
DockPanel Suite member
roken commented Sep 19, 2012

This is standard behavior for WinForms. A control container (like the FloatWindow) does not typically increase in size to accomodate a child control (like the DockContent) who is restricted by a MinimumSize. When the layout engine renders the controls it will render the child control at the minimum size but it will extend beyond the bounds of the parent container. As a simple case, this can be seen with a usercontrol docked in a form.

Extending the FloatWindow is the correct approach, setting a MinimumSize on the FloatWindow. If you're still setting a minimum size on the DockContent, the behavior I just mentioned is likely causing the overlap if the client area of the float window is reduced to less than the minimum size of the docked control. Don't set a minimum size on the dockcontent.

@TheRealWritz

But when the FloatWindow is tabbed I want to use the MinimumSize of the Current DockContent to calculate the MinimumSize of the FloatWindow. How can this be done??

Is there a Event when the Active Tab changes?? Then That can be utilized.

@roken
DockPanel Suite member
roken commented Sep 19, 2012

You need to add the non-client dimentions of the FloatWindow to your DockContent's MinimumSize when you set the FloatWindow's MinimumSize.

Assuming you're setting the FloatWindow's MinimumSize in the FloatWindow itself, you'd do something like this:

var ncWidth = Width - ClientSize.Width;
var ncHeight = Height - ClientSize.Height;
MinimumSize = new Size(yourDockContent.Width + ncWidth, 
                             yourDockContent.Height + ncHeight);
@TheRealWritz

As You commented the calculation was actually something similar that was imagined by me[ie with the ClientSize property]. But the problem is that I want to change the Size of the FloatWindow when the Tab changes. Other things are working well already.....

@roken
DockPanel Suite member
roken commented Sep 19, 2012

The code I provided calculates exactly what you're looking for... the size you need for the FloatWindow where yourDockContent is newly activated DockContent.

@TheRealWritz

That's OK! I placed a button in the MainForm to adjust the size but how do i get it done whenever the tab changes?? Is there any event??

@Topmoumoute

Hi,
I had the same problem and the solution worked great for the FloatWindow. I tried to had the same behaviour for the DockWindow to prevent user to shrink the docked control too much but it didn't worked (setting myDockContent.DockWindow.MinimumSize). Might be that i don't work with the right object.

Any hint ?

Thanks

@roken
DockPanel Suite member
roken commented Jul 20, 2013

FloatWindow is the top level control, which is why MinimumSize is respected when resizing. The Form that has the DockPanel would need to set its MinimumSize to restrict resizing; a standard WinForms behavior (this was already addressed previously above

@roken roken closed this Jul 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.