After I modified my application to the MDI application (main form became an MDI container), all of the shortcuts, which were specified int the main menu of the original form, are no longer works. What can I do in order to "turn them on" again?
The only thing that comes to mind is that you need to set the mdiparent property of any child form before you show it. You could have missed this when you switched the main form over.
Related
I'm making a WinForm app in C# (Visual studio) for fun. I came across a low-priority problem. It doesn't affect how the app works. But...
On the starting page, I have a button to open a Form1, inside Form1, there's a button to open a Form2 and so on.
At runtime, when I open a form, its parent form does not close and every form is a separate tab in the task-bar. As the layers grow, I'll have more-than-acceptable amount of tabs down there...
Is there a way to have only 1 tab?
I've tried:
Adding a parentForm.close() line when opening the form, but that was bad.
Instead of creating another form, putting everything in a panel, and bringing out another panel using code, but if there are too many layers, the code gets ridiculously long.
There has to be a simpler way right? Please shed some light.
Yes, you have a property in every form called ShowInTaskbar which is true by default. You can change that in the form properties under Window Style section or changing it by code manually:
Form2.ShowInTaskbar = false;
Form2.ShowDialog();
Configure to false all forms but the first one in order to achieve your desired behaviour.
Make sure your opened forms are dialogs or you are put them on top so user can never get in the situation where the form is behind and they cannot close it.
Anyway, with a proper form parenting configuration (if it fits your needs) you won't need this, as children forms won't appear in the taskbar.
If a form is parented within another form, the parented form is not displayed in the Windows taskbar.
Make sure you check the MSDN Documentation about this.
I have a main form with a MDI container active as well as a childform with a MDI container active. I want child form with mdi container act as parent to another form while main form is a mdi parent to child form with mdi container. How can I achieve this. I tried with below code for both the case but it showed error stating " A form cannot be Mdi parent as well as Mdi Child"
enter code here myform.MdiParent = this;
myform.Show();
You cannot - the message is quite clear about that. It's simply a limitation of the system. MDI is very old, and hasn't been updated in quite a long time.
If you need some alternatives, you could look at making windows not top-level, for example. The windows behave a bit differently (both from MDI and normal windows), but depending on your actual needs, they might be sufficient (or even better than MDI in the first place).
I have a form that is on the 2nd monitor and full-screen. I want to prevent all other windows from accidently being moved into the second screen and over lapping my form.
I also need to make sure that if a window gets moved to the other window and I use topmost, I don't want the other window to get lost.
I want to make the 2nd monitor( or my app ) un-overlappable. Not necessarily make it the topmost app.
This is a c# form.
What would be the best way to do this?
Form.TopMost property:
A topmost form is a form that overlaps all the other (non-topmost)
forms even if it is not the active or foreground form. Topmost forms
are always displayed at the highest point in the z-order of the
windows on the desktop. You can use this property to create a form
that is always displayed in your application, such as a Find and
Replace tool window.
I have a menu in C# which is not a menu strip but instead a System.Windows.Forms.MainMenu, a professional menu in C#, but it has a problem.
This MainMenu is in parent window, and when we open child windows in parent by clicking on menu, an icon on the left side appears, and the number of icons appear. If number of menus are clicked and their child forms opened, that completely disturbs the menu. Secondly when child forms open, cross and minimize icons also get together.
You can find the image attached to understand clearly what I mean. The image attached is when I clicked on 4 menus and 4 child forms opened in a parent form. Remember I open the form without deleting the previous instance, because I don't want the child which is opened should be cleared when re-opened.
This is caused by a bug in Winforms. Do not create the MDI child window in the constructor, do it in a Load event handler you write.
I have a project with multiple forms and when, for example, Form A opens Form B which opens Form C, then Form C is closed, Form B and Form A have gone to the back of the window order, so that whatever other programs are open are shown in front of these other forms in the project.
Why is this happening and how would I go about making sure the last opened form is shown when another form is closed?
Ensure that you are setting the Owner property of forms that are opened by other controls or Forms, either by setting the property explicitly or by passing the owner in as a parameter to Show() or ShowDialog().
You could track the "last" form in each of your forms, and on close, activate it. ie: if Form B opens Form C, Form C could keep a reference to Form B (or any form to activate on close), and force it to the foreground when you close your form.
That being said, I personally think that it's often better to just let the operating system perform its normal window manipulation/handling, unless there is a specific reason to override it. Applications that force their windows into the forefront often annoy me - instead of being beneficial, it can be disruptive to your users.
You could have a series of Dialog forms opened from a single form, in order. What this allows you to do is check the DialogResult - you'd then be able to control the direction in which you open new forms or show old forms.
If you're worried about the z-order of so many forms, you might consider changing your UI to avoid multiple non-modal windows.
Well maybe you need to set up the new forms as a modal dialog with the ownership to the older forms. This way when the new form closes the new form will be visible. Additionally as long as the new form is open, nobody will be able to access the older forms.