System.Windows.Forms.MainMenu has a problem with merging elements - c#

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.

Related

VS Designer Now Showing MainMenu

I can't seem to fix this issue (which i hope is small) i have somehow when adding a ContextMenu did something to have the MainMenu bar not show up when i debug, if i click on the "MainMenu" in the designer (1st image) the menu bar shows up in the designer fine:
But if i click off it, then click on another control like:
The MainMenu disappears from the designer, when i build / debug the MainMenu is gone, is there a way to fix this easily enough (i assumed it would be as simple as checking a setting but googling did not return anything that i saw that was helpful)
Any help would be appreciated.
It looks like your MainMenu has ended up hidden behind your other controls. Try right clicking on the main menu and selecting Bring To Front. If you can't right click on it, right click on the control that's filling the rest of the form and select Send to back.
When you click on a menu control in the component tray it will always show it at the top of the screen (even if you click on a ContextMenu).
One other thing worth doing is to open the Document Outline window from the View->Other Windows menu in Visual Studio. This gives you a hierarchichal view of all the controls on the current form. You should be able to see your main menu here (unless you've somehow removed it from your form!)

Navigate on several WinForms in a C# app

I'm building a C# form application which contains several forms. (Login, Menu, Products, Users, Settings..etc).
This is the structure how the navigation happens.
Currently what I'm doing is hide the current form and create a new object of the next form and display it.
this.Hide();
Menu obj = new Menu();
obj.Show();
If I create objects for each visit to a form, there'll be lot of objects of that form. Right ?
Is this the correct way of doing it ?
And some of the navigation are bidirectional. There's a button on each form to go back.
So, what's the efficient way of closing the current form and go to next.
I think a better (this is subjective) flow would be:
Login and Menu are Forms that are considered top level.
When Login is complete, it is closed (not hidden), and Menu appears as the only form.
From Menu, you can pop-up Modal dialogs for the other screens. But only one of them can be open at a time. When they're closed, the user can control the Menu form again and open another screen.
Note, by Modal dialogs, they would appear on top of the Menu form, but Menu wouldn't be hidden. It is simply waiting for the modal to be closed before it regains control.
The problem with windows that appear and disappear (regardless of whether they are closed or hidden) is that the end result may be disconcerting to the user. They may feel that the program has quit and the link between prior and consecutive windows may not be easily understood.
UserControls
Alternatively you may want to consider replacing your other windows with UserControls. This way you have a main window that consistantly stays open and you simply embed a UserControl representing the other pages into it. Thus making it more obvious to the user that there is a notion of an consistent "app".
Users; Products and Settings, instead of deriving from Form would instead derive from UserControl. To move from say Users to Products, simply remove Users from the Controls property; create a Products control and add it to Controls ensuring that it is set to Dock.Fill.
I see no reason why Login still can't remain a modal dialog though.

How to use the menu strip to show all open MDI forms C#

I need to display all open MDI forms when I click the window button in the menu strip. It should drop down and give you an option to select the active one. This is probably some simple answer but I have looked in so many places.
I think you want this:
which you get by setting the property MdiWindowListItem on the menu strip

Using one Windows Form - Visual Studios c#

I am making a Multiple Choice test application using Windows Forms on Visual Studios. When a user answer one question, they will click next to proceed to the next question. Would I be able to use a single windows frame to display all my questions? When I do it on more then one windows form I had to do this.Hide() and then .Show() the other form. I don't have a problem with doing this but when it hide and shows the other windows form it isn't open on exact same position, it keeps moving.
You can create a UserControl that displays the question and the multiple choice answers. When the user clicks the Next button, you remove the UserControl from your form's Controls collection, create a new instance of your custom UserControl with the next question's details on it, and then add the new instance to your form's Controls collections. This structure will let you do the app on a single Form.
I would better suggest you to use Panel form the tool box for multiple forms. It would be better for the multiple choice questions.
Then for every panel use property visible set to either True or false depending on which panel you want to navigate.
See this to understand more in detail
http://www.youtube.com/watch?v=CDOXzz_0gYE&feature=related
You can use wizard.
Here you have two links:
http://www.codeproject.com/Articles/18674/A-Simple-Wizard-Control-for-Net-2-0-with-Full-Desi
Add this library to Toolbox:
Right click on the Toolbox and select "Add Tab" from the context menu.
Specify name for the newly created tab, such as "Wizard".
Activate the tab, right click on it and select "Choose Items..." for the context menu.
Now browse to the folder where is assembly "WizardBase.dll" and select it.
http://winformswizard.codeplex.com/
The simpler the better.
The simplest way is to make a panel, (in one window), and then add labels with your question and all options of the answer in that panel. Then on the click on the NEXT button, change the texts of all the labels at once.
As far as your problem of opening different windows on the same position on the screen, change the DefaultPosition property of all the forms to CenterScreen or CenterParent.

Menu shortcuts and MDI in Windows forms

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.

Categories