Problem when adding to a SplitContainer
-
Hi, I'm trying to create a MDI window which has a SplitContainer, on the left SplitterPanel a treeview and when a node is double clicked a Form should open in the right SplitterPanel. I'm trying to make the Form a child of the MDI Window and also display it within the right SplitterPanel. The problem is that, when I double click the TreeView node, the Form which is added to the right Splitter Panel is not added as a child of the MDI and it also does not have focus. I can move the Form window and access its controls, but it does not retain focus. This is the code I used to add the Form ( done within the Constructor) // g_mdiform is a instance of the MDI window // g_mdiform.WorkingPanel returns the right SplitterPanel this.MdiParent = g_mdiform; g_mdiform.WorkingPanel.Controls.Add(this); I tried the following code within the Mdi Window class as a test. Form frm = new Form(); frm.SetBounds(100, 20, 100, 100); frm.MdiParent = this; splMDIPane.Panel2.Controls.Add(frm); frm.Show(); The above problem still exists.... If anyone knows how I can resolve this, please let me know... Thanks Mahesh
-
Hi, I'm trying to create a MDI window which has a SplitContainer, on the left SplitterPanel a treeview and when a node is double clicked a Form should open in the right SplitterPanel. I'm trying to make the Form a child of the MDI Window and also display it within the right SplitterPanel. The problem is that, when I double click the TreeView node, the Form which is added to the right Splitter Panel is not added as a child of the MDI and it also does not have focus. I can move the Form window and access its controls, but it does not retain focus. This is the code I used to add the Form ( done within the Constructor) // g_mdiform is a instance of the MDI window // g_mdiform.WorkingPanel returns the right SplitterPanel this.MdiParent = g_mdiform; g_mdiform.WorkingPanel.Controls.Add(this); I tried the following code within the Mdi Window class as a test. Form frm = new Form(); frm.SetBounds(100, 20, 100, 100); frm.MdiParent = this; splMDIPane.Panel2.Controls.Add(frm); frm.Show(); The above problem still exists.... If anyone knows how I can resolve this, please let me know... Thanks Mahesh
Hi, Mahesh. If you want to create a classic MDI application then you shouldn't use SplitterPanel in your main form. You just need to follow next steps: 1. Set MainForm.IsMdiContainer = true. 2. Add a TreeView to the MainForm and set treeView.Dock = Left. 3. Add a Splitter to the MainForm and set splitter.Dock = Left. 4. When you need to create MDI child use this:
ChildForm child = new ChildForm();
child.MdiParent = this;
child.Show(); -
Hi, Mahesh. If you want to create a classic MDI application then you shouldn't use SplitterPanel in your main form. You just need to follow next steps: 1. Set MainForm.IsMdiContainer = true. 2. Add a TreeView to the MainForm and set treeView.Dock = Left. 3. Add a Splitter to the MainForm and set splitter.Dock = Left. 4. When you need to create MDI child use this:
ChildForm child = new ChildForm();
child.MdiParent = this;
child.Show();Hi Andrew, Thanks :-) I was trying to create a Tree navigator that could be hidden or moved out of the way if required... :-D I'm still new to C# and doing a project for my degree. I was trying to get a Navigator which is Dockable and Floatable. I was trying to use a SplitContainer so that the Navigator could be hidden when not required. I found a third party library (from a code project article) called Magic Library, which provides a great docking manager... It seems to provide the functionality that I require. I'm trying to use that for the Tree Navigator. thanks again for ur help :-) Mahesh