Background (nonsense and think): Contact .Net has been long time, but there is no time to study hard, just just some understandings. I fully learn C #, asp.net, ADO.NET has been more than a week, and it is studying with a project! :) First of all, I paid a lot of bookstores, bought a bunch of books, including "ADO.NET programming"
Netizen Solution: First, 1. Do a landing form, put the main () method in this form, let it do the main form; 2. Construction of your original main window (you want to modify the menu property) A INT type parameter logintype; 3. Set an int value in the "OK" button event of the login form, such as the administrator is 0, the general user is 1, etc. Then generate the main form of the menu and pass this integer to its constructor; 4. Which of the menu item is set according to the value of logintype in the Form_Load event of the host's main form, which is not available. use. Hope it helps you :)
I understand this program:
Thank you very much for your advice! For this approach, it is a bit a bit a bit not in line with my needs. I want to load a user login interface when I am loaded in the main window (ie the menu). Sign in successfully closes this login interface and then displays a specific menu in the main window according to the user type. If the user closes this login interface, all menus are prohibited. I first used your approach, but after displaying the main form, the login form cannot be turned off, one closed this login window The main window is also turned off because the main function main () is in the login window. Although you can use the hidden login window, I have not tried it! :)
Second, the following method can be made, after the user starts the program, the main window will appear first, but the menu is all disabled, then the landing window appears, the user must log in, otherwise it will be exited. After the user login, according to different The user displays the different menus .1, the main form frmmain is the startup form, that is, this form contains main (). Prince string strlogin = ""; private void frmmain_load () {// Disable all menus} private void frmmain_activate () {If (this.strlogin! = ") Return; frmlogin myfrmlogin = new frmlogin (); if (myfrogin.myshowdialog (ref strlogin)) {this.close (); return;} // then determine the login user type, decision Those menus are displayed.} 2, design login window frmlogin. Public bool myfrmshowdialog (String Ref strplogin) {this.showdialog (); // Return to the login user. If (userCancel) returnaf false; // User cancel, return to fake strplogin = usrinfo Return True;} I understand this program: Your suggestion is very compliant with my needs, but private void frmmain_activate () This event I don't know much, so I can't solve it! I checked WinCV and found that there is Activate event, but I don't know how to use it! What is the specific? Can I refer to what kind of book?
I summarize the netizen program: Given the two practices, I summed up a principle, that is, transmit parameters, used to save user type information! :)
My solution:
I designed my login program like this, everyone will give you some opinions! 1. In the load function in the main window. Private void form_main_load (Object sender, system.eventargs e) {form_login frm = new form_login (); // Create a login window frm.showdialog (); // Display this login window if (frm.ReturnUsertype () == 1) // Returned User Type {// Add modified menu attribute code!
} Else if (frm.returnUsertype () == 2) {// Add modified menu property code! } Else if (frm.returnUsertype () == 3) {// Here you add to modify the menu property code! } Else {//frm.close ();}} 2, in the login window, add a user type variable for the login window class, Private Int Usertype;
3. In the login window, add a public function to the login window class to return user type information! Public int ReturnUsertype () {return this.usertype;} 4, save your user type information in the login window, save your user type information! Private void button1_click (object sender, system.eventargs e) {// Some login database, verification process this.usertype = 1; //this.close (); // ....... this.usertype = 2; ///// .........} My program summary: Although the problem has been resolved, I found to close the login window is a problem. Solve in Button1_Click, or solve it in Form_Main_Load!
The first time I wrote something, not very good! I hope this is helpful for beginners or need this knowledge!
Finally, I am particularly grateful to Demonhunter of the 9CBS Forum (no words), Souther (South Wind)
See quite: http: //expert.9cbs.net/expert/topic/1681/1681684.xml? Temp = .1134607
Technical exchange: hgf686@sina.com
Copyright, you can reprint, huh, huh! ~~
Do you have any good comments, please send me an email! Thank you!