Open Form Incide another Form
-
Hi I create a main Form with a splitContainer In the Left panel I put a Tree View In the Right panel I like to open diferent forms according to de selected information in the treeview. Example Tre view - Item - Customer xxx When double click on on this customer a new CustomerFor with customer details open in Right panel If anoter customer yyy is selected a second CustomerForm open in the same panel A sort of tabContol cold be use to swich between Customer xxx and Customer yyy I try with MDE but I dont know hot to restrict the opening of the Child forms to the right panel of the splitContainer or anoder object capable of containing Forms. any clue?
-
Hi I create a main Form with a splitContainer In the Left panel I put a Tree View In the Right panel I like to open diferent forms according to de selected information in the treeview. Example Tre view - Item - Customer xxx When double click on on this customer a new CustomerFor with customer details open in Right panel If anoter customer yyy is selected a second CustomerForm open in the same panel A sort of tabContol cold be use to swich between Customer xxx and Customer yyy I try with MDE but I dont know hot to restrict the opening of the Child forms to the right panel of the splitContainer or anoder object capable of containing Forms. any clue?
I do not know of a way to constrain a form within another form. I don't think that it is possible in C#, perhaps someone with more knowledge will respond and let you know. However, what you can do is build a 'customer' control. Add a new User Control to your project and design it like you would a form. Add this control to the right panel. Then, when the TreeView is clicked, just fill whatever controls you have put on your 'customer' control with the data for that customer. You can then have a separate form just containing the new control, for occasions when it is more appropriate to display it as a form.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
Hi I create a main Form with a splitContainer In the Left panel I put a Tree View In the Right panel I like to open diferent forms according to de selected information in the treeview. Example Tre view - Item - Customer xxx When double click on on this customer a new CustomerFor with customer details open in Right panel If anoter customer yyy is selected a second CustomerForm open in the same panel A sort of tabContol cold be use to swich between Customer xxx and Customer yyy I try with MDE but I dont know hot to restrict the opening of the Child forms to the right panel of the splitContainer or anoder object capable of containing Forms. any clue?
Hey Christian, I am having exactly the same problem. I use a SplitContainer and and have placed a TreeView control inside. In the right side of the split container, one of five different Forms shall be loaded, depending on what's selected in the TreeView. Up to now, I unfortunately have not found a solution, but I'm new to C#, so this does not mean anything ;-) "SubForms" even work in LabVIEW, so I would be very amazed, if C# would be unable to do the same... Peter
-
Hey Christian, I am having exactly the same problem. I use a SplitContainer and and have placed a TreeView control inside. In the right side of the split container, one of five different Forms shall be loaded, depending on what's selected in the TreeView. Up to now, I unfortunately have not found a solution, but I'm new to C#, so this does not mean anything ;-) "SubForms" even work in LabVIEW, so I would be very amazed, if C# would be unable to do the same... Peter
I have seen this in 3P Component, I think it was .Net Bar But this is out of my budget, So I'm trying to develop a solution with the component that come with C#. If I find something I let you know. Cristian
-
I do not know of a way to constrain a form within another form. I don't think that it is possible in C#, perhaps someone with more knowledge will respond and let you know. However, what you can do is build a 'customer' control. Add a new User Control to your project and design it like you would a form. Add this control to the right panel. Then, when the TreeView is clicked, just fill whatever controls you have put on your 'customer' control with the data for that customer. You can then have a separate form just containing the new control, for occasions when it is more appropriate to display it as a form.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
Henry is definitely on the right track. Think of forms as layouts. Which in turn have panels. You then create a user control for the "subform" and load it into the right panel of the main form. This works extremely well and now you can decouple your views and reuse them in different layouts and containers. I hope that this helps you.
-
I have seen this in 3P Component, I think it was .Net Bar But this is out of my budget, So I'm trying to develop a solution with the component that come with C#. If I find something I let you know. Cristian
Ok, that sounds fine. Thank you! Peter
-
I do not know of a way to constrain a form within another form. I don't think that it is possible in C#, perhaps someone with more knowledge will respond and let you know. However, what you can do is build a 'customer' control. Add a new User Control to your project and design it like you would a form. Add this control to the right panel. Then, when the TreeView is clicked, just fill whatever controls you have put on your 'customer' control with the data for that customer. You can then have a separate form just containing the new control, for occasions when it is more appropriate to display it as a form.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
I think is a good idea But very complex to maintain We are all use of this kind of interface The IDE work exactly as I want: Multiple pages, im my case Forms The tree view is the solution explorer. How could be this so dificult to replicate. :( Cristian
-
Hi I create a main Form with a splitContainer In the Left panel I put a Tree View In the Right panel I like to open diferent forms according to de selected information in the treeview. Example Tre view - Item - Customer xxx When double click on on this customer a new CustomerFor with customer details open in Right panel If anoter customer yyy is selected a second CustomerForm open in the same panel A sort of tabContol cold be use to swich between Customer xxx and Customer yyy I try with MDE but I dont know hot to restrict the opening of the Child forms to the right panel of the splitContainer or anoder object capable of containing Forms. any clue?
-
Hi I create a main Form with a splitContainer In the Left panel I put a Tree View In the Right panel I like to open diferent forms according to de selected information in the treeview. Example Tre view - Item - Customer xxx When double click on on this customer a new CustomerFor with customer details open in Right panel If anoter customer yyy is selected a second CustomerForm open in the same panel A sort of tabContol cold be use to swich between Customer xxx and Customer yyy I try with MDE but I dont know hot to restrict the opening of the Child forms to the right panel of the splitContainer or anoder object capable of containing Forms. any clue?
Perhaps you could use the NativeWindow class, passing a CreateParams structure with its Parent property set to the Handle property of the right handle Panel. Then, display the form and use the SetParent PInvoke call to make it a child window of the parent Pseudocode:
NativeWindow wnd = new NativeWindow(new CreateParams()
{
Parent = rightHandPanel.Handle,
Height = rightHandPanel.Height,
Width = rightHandPanel.Width,
X = Y = 0
}
Form display = formYouWantToDisplay;wnd.CreateHandle();
display.Show(wnd); //This works because NativeWindow implements IWin32WindowThis would require quite a bit of research to work properly I think. Are you sure you don't just want to have an MDI parent, and dock a panel containing a treeview to the left hand side?
modified on Sunday, March 1, 2009 1:54 PM
-
I think is a good idea But very complex to maintain We are all use of this kind of interface The IDE work exactly as I want: Multiple pages, im my case Forms The tree view is the solution explorer. How could be this so dificult to replicate. :( Cristian
If you are absolutely determined to do 'Form Docking', it can be done. But not in pure c#. A great deal of P/Invoke is required, to get this functionality. Take a look at this[^] for examples.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
I think is a good idea But very complex to maintain We are all use of this kind of interface The IDE work exactly as I want: Multiple pages, im my case Forms The tree view is the solution explorer. How could be this so dificult to replicate. :( Cristian
I take back some of my last post. I have just read Eddy Vluggens response. This definitely CAN be done in pure c#. :) Very slight modification to his code
private void btnForm\_Click(object sender, EventArgs e) { Form newForm = new Form(); newForm.TopLevel = false; newForm.Parent = this; newForm.Visible = true; newForm.Location = new Point(10, 10); newForm.Size = new Size(this.ClientSize.Width - 20, this.ClientSize.Height - this.panel1.Height - 20); newForm.BackColor = Color.Bisque; newForm.FormBorderStyle = FormBorderStyle.None; this.Controls.Add(newForm); }
getting rid of the border, to save you having to look it up if you weren't aware of it already.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
Hi I create a main Form with a splitContainer In the Left panel I put a Tree View In the Right panel I like to open diferent forms according to de selected information in the treeview. Example Tre view - Item - Customer xxx When double click on on this customer a new CustomerFor with customer details open in Right panel If anoter customer yyy is selected a second CustomerForm open in the same panel A sort of tabContol cold be use to swich between Customer xxx and Customer yyy I try with MDE but I dont know hot to restrict the opening of the Child forms to the right panel of the splitContainer or anoder object capable of containing Forms. any clue?
If you use MDI, you can't exactly control where the
MdiClient
(which is where MDI children are located) window goes. However, I would try this (I once tried something similar and it worked): 1. Create your main form 2. Set itsIsMdiContainer
property to true 3. Add a panel and dock it to the left of your main form. [EDIT: If you want a splitter, add it here and also dock it to the left. But don't add aSplitContainer
, but an original Splitter[^] control.] 4. Add theTreeView
and whatever else inside that panel When you create MDI children, they will be located inside the MDI client area, which will be to the right of your tree view. I hope this helps :)Luis Alonso Ramos Intelectix Chihuahua, Mexico My Blog!
-
Hi I create a main Form with a splitContainer In the Left panel I put a Tree View In the Right panel I like to open diferent forms according to de selected information in the treeview. Example Tre view - Item - Customer xxx When double click on on this customer a new CustomerFor with customer details open in Right panel If anoter customer yyy is selected a second CustomerForm open in the same panel A sort of tabContol cold be use to swich between Customer xxx and Customer yyy I try with MDE but I dont know hot to restrict the opening of the Child forms to the right panel of the splitContainer or anoder object capable of containing Forms. any clue?
Hi evirione For any one interest in this Here I publish my solution Object in Form1 splitContainer1 tabControl1 (in the right panel of the splitContainer1) The tabControl does not have any page on design. The left panel I intent to put a treeView, but for this code, there is a button button1 (in the left panel of the splitContainer1) this is the code for the button click event
private void button1\_Click(object sender, EventArgs e) { TabPage newTabPage = new TabPage("Form " + tabControl1.TabPages.Count); newTabPage.Size = new Size(tabControl1.Width, tabControl1.Height); Form2 newForm = new Form2(); newForm.TopLevel = false; newForm.Parent = this; newForm.Visible = true; newForm.Location = newTabPage.Location; newForm.Location = new Point(3, 3); newForm.Size = new Size(newTabPage.Width - 3, newTabPage.Height - 3); newForm.FormBorderStyle = FormBorderStyle.None; newTabPage.Controls.Add(newForm); tabControl1.TabPages.Add(newTabPage); }
Becaus Microsoft does not provide the Tab control we all use in the IDE, that allow to close a tabpage with an X in the upper right corner, I have no alternative and just use a normal tabControl Now, in order to destroy the tabpage when closing the form created on each page. In Form2 I add a button, and the followin code.( this close the form and destroy the tab page.
private void button1\_Click(object sender, EventArgs e) { TabPage tab = this.Parent as TabPage; TabControl tabControl = tab.Parent as TabControl; tabControl.TabPages.Remove(tab); this.Dispose(); }
Hope this help Cristian Conrads
modified on Monday, March 2, 2009 7:05 PM