Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Change your login form so that it returns DialogResult.OK when login is successful:</p> <pre><code>public partial class loginfrm : Form { public enum UserTypes { admin, salesman, accountant, stockmanager } private UserTypes _UserType; public UserTypes UserType { get { return _UserType; } } public loginfrm() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (txt_userid.Text == "user" &amp;&amp; txt_password.Text == "user") { // ... set _UserType somehow ... this._UserType = UserTypes.salesman; this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show("Invalid User Name &amp; password", "Error"); } } } </code></pre> <p>Now, back in your main form, you can check that result and change the TabControl directly:</p> <pre><code> private void fudafrm_Load(object sender, EventArgs e) { this.Hide(); // not necessary from the Load() event loginfrm f2 = new loginfrm(); if (f2.ShowDialog() == System.Windows.Forms.DialogResult.OK) { switch(f2.UserType) { case loginfrm.UserTypes.admin: // remove nothing break; case loginfrm.UserTypes.salesman: tabControl1.TabPages.Remove(tabPage1); tabControl1.TabPages.Remove(tabPage3); break; case loginfrm.UserTypes.accountant: tabControl1.TabPages.Remove(tabPage1); tabControl1.TabPages.Remove(tabPage2); tabControl1.TabPages.Remove(tabPage5); break; case loginfrm.UserTypes.stockmanager: tabControl1.TabPages.Remove(tabPage1); tabControl1.TabPages.Remove(tabPage4); tabControl1.TabPages.Remove(tabPage7); tabControl1.TabPages.Remove(tabPage8); break; } } else { Application.Exit(); // ? } } </code></pre> <p>You can set DialogResult to Cancel to indicate a failed login.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload