Only one DockContent in DockPanel

谁说胖子不能爱 提交于 2019-12-11 09:22:47

问题


Here is how my setup looking:

This is the DockPanel suite. The white area is dockPanel visual component I has dropped on form. I don't need any docking, nested docking, droppable tabs, etc. I just need one "ProjectsForm" panel and want it to auto hide and hide by user clickings.

So, my questions is how can I transform previous picture to look like this new one:

How can I forbid to make this one panel float?

Here is some code:

private void MainForm_Load(object sender, EventArgs e)
{
    DockContent dockProjectsContent = new ProjectsForm();
    dockProjectsContent.AllowDrop = false;
    dockProjectsContent.AllowEndUserDocking = false;
    dockProjectsContent.ShowHint = DockState.DockLeft;            
    dockProjectsContent.Show(dockProjects);            
}

回答1:


Why don't you create a DockContent for the "body" of your form (you're not going to leave it empty like that are you?!) open that in the middle of the dock panel?!

First you'll need to set the dockpanel's DocumentStyle to "DockingWindow"

dockProjects.DocumentStyle = DocumentStyle.DockingWindow

then..

dockProjectsContent.Show(this.dp, DockState.DockRight);
dockMainContent.Show(this.dp, DockState.Document);

Then check out all the different DockContent properties you can set..

dockProjectsContent.AllowEndUserDocking = false;

I'm sure there are others you want to set like prevent the user from closing any of them!



来源:https://stackoverflow.com/questions/10107461/only-one-dockcontent-in-dockpanel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!