Making main menu's menu boxes pop down programatically

aewarnick

Senior Contributor
Joined
Jan 29, 2003
Messages
1,031
This is what I have done so far:
When the user clicks this menu item all the menu items clear and a password prompt comes up. If the password is correct the menu items are added to the box again.

That works fine but the problem is that after the password is entered correctly, the user would expect the box to be shown, but I cannot figure out how to do that. I tried using PerformClick() but that did nothing at all.
Code:
private void RepairMImain_Select(object sender, System.EventArgs e)
		{
			this.RepairMImain.MenuItems.Clear();
			PassForm P=new PassForm();
			DialogResult R= P.ShowDialog();
			if(R==DialogResult.Yes)
			{
				this.RepairMImain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
				this.RepairMI,  this.AboutRepairFilesMI,  this.ViewBackupMI,  this.AboutBackupMI});
				
			}
		}
 
Are you saying that you prompt for a password every time the user clicks on your main menu item? Wouldn't it be MUCH simpler to prompt for a password at some other point (when starting up the main form, for instance). If they don't enter the right password, just don't show the app at all or hide all menus except for Exit or File->Exit.

-Nerseus
 
No. Every day the program will be used by many different users without shutting the program down each time.
 
We have the same type of program here, but it still seems easier to provide a Log Out/Log In type of function (if you don't want them to have to close/open the program) than to try and ask for a user/pass on every menu click.

-Nerseus
 
I did that at first but. . .

The reason I chose to put the user pass at the point when the user clicks on the main mi is because I do not want a user who does not have the pass to even see the menu items.
 
Back
Top