问题
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