c# - How to close Login form which is coded into Form1 then show another form? -
i have loginform coded mainform or form1, if inputed credentials correct directed form2 , loginform close, , form2 contains logout button, , if click logout button go loginform , input again credentials.
i want close or not shown in taskbar icon loginform when i'm login, want see 1 icon not 2 icon in taskbar.
note: loginform in form1, , form2 form.
void btnlogin_click(object sender, eventargs e) { bool error = true; if ((txtuserlog.text.trim() == "") || (txtpasslog.text.trim() == "")) { messagebox.show("please fill fields!"); } cfgotcall.tether(settings); cfgotcall.engagequery("select * tblusers"); unitbl = cfgotcall.tbl; cfgotcall.untether(); (int = 0; < unitbl.rows.count; i++) { if ((unitbl.rows[i].itemarray.elementat(2).tostring().equals(txtuserlog.text, stringcomparison.ordinalignorecase)) && (unitbl.rows[i].itemarray.elementat(3).equals(txtpasslog.text))) { if (unitbl.rows[i].itemarray.elementat(4).tostring().equals("registrar", stringcomparison.ordinalignorecase)) { error = false; = unitbl.rows.count; cfgotcall.engagequery("select * tblusers"); frminterface sfinterface = new frminterface(); sfinterface.enable_mnusim(true); sfinterface.showdialog(); } else if (unitbl.rows[i].itemarray.elementat(4).tostring().equals("accounting", stringcomparison.ordinalignorecase)) { error = false; = unitbl.rows.count; cfgotcall.engagequery("select * tblusers"); frminterface sfinterface = new frminterface(); sfinterface.enable_mnusam(true); sfinterface.showdialog(); } }
additional correct answer of @slashy:
"use form1.visible = false;" or "this.visible = false;" because .close() on mainform exists whole program. #edit: ".hide()" @slashy edited possibility :)
you shouldn't continue after showing messagebox wouldn't make sense, like:
if ((txtuserlog.text.trim() == "") || (txtpasslog.text.trim() == "")) { messagebox.show("please fill fields!"); return; // abort continuing when no data entered }
Comments
Post a Comment