i'm new to Windows forms, i searched but didn't find any answer to my problem.
I have a Form that will be my main Windows, and i want to integrated other form in a specific space of my main window.
To be more precise, i have my MainWindow, the user will select what specific fonctionality he want to access and his choice will load another form in the dedicated space below
(for exemple :
- a form that manage every user
- a form that create and manage data
- etc...
I saw you can "load" other form by setting the parent of the form to anoter, but it's like having a window in a window.
what i'm searching, is more like a "fragment" of a IHM, that still has the class[Design] for personification, but dosen't have the close and other window functionnalities.
Im' really sorry guys, yeah i just had to make my borderstyle none.
Really sorry to made you loose your time, and thanks for the answer
Reports rep = new Reports();
rep.FormBorderStyle = FormBorderStyle.None;
rep.MdiParent = this;
rep.Show();
Related
I want to know how to open different forms with a single main parent form in Metro Framework UI similar to a Modern POS System. As far as I know, I haven't found anything remotely close to that in the internet and I'm also having trouble trying to figure it out in Metro. Also I'm not talking about MDI Forms
Here's an example: (not in Metro)
Modern POS Design (watch first few seconds of the vid)
I'm talking about a dashboard type of UI where you open different modules using buttons on the left side of the Main form and the modules are opened as a child form in the Main form.
It has so many bugs when it comes to that kind of procedure. You can just use a simple form rather that MetroForm because MetroForm creates a somewhat black form on your screen when calling as child form. I don't know if it just in my application but it is really annoying.
You can just add your other forms to a panel at your main form.
There are many tutorials on how to do this but i will give you an example.
I created a method something like this in my utilclass:
public static Form NewForm(Form myForm, Panel myPanel)
{
myForm.TopLevel = false;
myForm.AutoScroll = true;
myForm.Dock = DockStyle.Fill;
myPanel.Controls.Clear();
myPanel.Controls.Add(myForm);
myForm.Show();
return myForm;
}
then calling from Main form to a panel:
Form2 myForm2 = new Form2();
UtilClass.NewForm(myForm2 , [YourMainFormPanel]);
I know this code is not the best approach but I'm just giving you ideas.
My main form is this
Now my problem occurs when I click Add -> Student, which is meant to bring up a new window that, instead it does this
So as you can see it opens the new form inside the same window. It didn't use to do this, then I made the main form an MdiContainer and set it as the MdiParent of the second form.
Is there a property I can change to make this new form pop up in a new window? Becuase I need to leave the MdiContainer property as True so that I can take data from Form2 and use it in Form1
Please let me know any other information you may need to help me fix this issue, as I'm not sure what caused it so I don't know what to change in order to fix it or even where I'm meant to be looking
you need to hide form enroll
when you open add window add.show()
you need to hide enroll form enroll.hide()
In Form1 I'm enabling IsMdiContainer and I added a MenuStrip. In Form1_Load I "new" Form2 and I'm assiging Form2.MdiParent to this which is Form1. I'm also maximizing Form2 and this operation works well.
In Form2 I have a treeView on the left side of the form and on the right side of the form I would like to display a number of different forms with various editing capabilities which will be dependent upon the node or level selected in the treeView.
I would like to create a number of different forms for editing data that would be displayed in Form2 depending on the selection from the treeView. I can't seem to add a form to the MdiChild and I've been seeing some posts where adding a form to a form may create some programming problems which I'm not sure about.
I really don't have any code to paste into this post because nothing seemed to work except for the Mdi Parent and Child relationship which was pretty simple.
Thanks in advance for any help.
There is a lot of information on this subject, but some documentation can be difficult to understand for some new developers. Follow these steps:
Open Visual Studio
Create a Windows Form Application
Click your Form
Go to Properties for that Form
Minimum Size : 1366 pixels by 768 pixels.
Launch Maximized
The important element is IsMdiContainer
Open your Toolbox.
Go to Menus
Drag FileMenu onto your Form
Build your Menu
Then go to Solution Explorer
Right-Click Add Item
Add another Form
I left mine as Form2 (In a real program, not a good name).
So within those fifteen steps, we have all that we need to accomplish our goal. So what we will do to finish our task is:
Go back to our First Form
Go to our FileMenu
Double Click on the menu button you wish to link.
It will load a code view, inside the area put this:
Form2 newFrm = new Form2();
newFrm.MdiParent = this;
newFrm.Show();
What this code is doing is three distinct things:
Line 1: It is actually calling our object, in this case a second form. It is actually building our object for us.
Line 2: Is actually linking our second form to our current form, this is physically turning our second form into a Child Form.
Line 3: This is actually physically showing our second form when the button is clicked.
That is all you need to physically show a Form.
In regards to your second question, I'm not entirely sure what your attempting to accomplish. It sounds like your trying to have a tree, then as a Node is selected the right hand side of the Form changes to specific context.
Now this isn't the nicest example, but do you mean something like this?
TreeNode node = treeView1.SelectedNode;
if (node.Text.Contains("XP"))
{
TextBox one = new TextBox();
Panel i = new Panel();
i.Dock = DockStyle.Right;
i.BackColor = Color.Black;
i.Controls.Add(one);
i.Show();
TreeFrm.ActiveForm.Controls.Add(i);
}
Not sure if that is what you are seeking. Obviously you'd want to implement a FlowLayoutPanel to make the positioning not a pain for you. Keep in mind an MDI Parent, with a Child Form acting as a MDI Parent will not work very well. As most things will default to MDI Parent Forms Docking / Positioning. This example is not pretty, but I'm not entirely sure of what your asking.
Are you trying to dock other forms or components on the same form?
I want a form to be shown modal every time it is opend. Since I can not change the way it is created and opend. I wondered if it is possible to make the form stay on top from within the forms class.
One opportunity is the TopMost property. This works in general, but if I display the form while the main thread is waiting for it to close, the form will stay on top even if I change the application(to a browser for example). So no matter where I am, the form is still displayed.
Another issue which I came across is that in some cases it is adopted by the parent form which then might block other windows or popup messages.
I was thinking about a hook to the OnLostFocus event to get it on top again, once the focus is lost, but I'm not sure if that is a good idea ...
Any helpful thoughts about it?
Edit
Due to the comments I will extend my description, Here is the real use-case
We are using the Devexpress's SplashScreenManager which is able to show a certain form as a WaitForm. Since the WaitForm is not intended to be shown modal(see on the Support Center), we are looking for a way to do so.
We can not change the way the form is shown, because this is done through the SplashScreenManager. The WaitForm is shown both from the main thread, as well as from certain backgroundworker.
So this is only about an own form of ourselfs, displaying it within our own application.
Use:
TopLevel = true;
This will do exactly what you want; be topmost as long as the main form is shown and hide if the mainform is hidden by another window.
You can set the owner of your splash form to your main form explicitly without using .Show(owner).
splashForm.Owner=mainForm;
splashManager.Show(splashForm);
We did not want the TopMost property since it works on windows level and covers other windows too (for example the browser).
In the end I hooked up on the focus event of the window to make sure the window is always on top.
In an internet webpage , there is a constant menu usually placed on the top or left of a page from which user can navigate (They call it Iframes) ..
I would like to know if it is possible to do something like that using WinForm applications or WPF applications in c# .
At present I am simply inheriting forms from a base class . and each time the user needs to navigate , I have no option but to open up a new form with the same Peristent menu ...
Any suggestions here ?
I managed to use usercontrol to embed a form into another ..
Form1 has a userControl , Form2 embedded inside the user control .
things to note was ..
the embedded forms toplevel property should be set to false
the embedded forms FormBorderStyle should be set to none
userControl1.Controls.Clear();
Form2 f = new Form2();
f.Toplevel=flase;
f.Show();
f.TopLevel = false;
userControl1.Controls.Add(f);
You could use an MDI-container in WinForms.
see here and here for more information.
You mean like an MDI application (http://www.codeproject.com/KB/cs/myBestMDI.aspx) or just using a SplitContainer on the form? Really there are many options. WPF has ElementHost I think. Did you do any research yet? What did you find?
You could also take the toolbox approach. Have a parent program start the menu form and then other forms can use it... or it can launch from it... what ever your use case is.
Well, there should be a frame component in WPF which will give you such an option. Then you would use a "view" concept to open the WPF Pages you direct the user to.