hello
how to hide and show tabpages by user privileges
thank you for your cooperation
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sam HobbsRank #107 · 20.5K reputationPosted Jul 2, 2010, 5:48 PM EDT
Mesha23 reputationPosted Jul 2, 2010, 11:32 PM EDT
this is the code of hide tabpages
//this button in form1
private void button1_Click(object sender, EventArgs e)
{
Form2.tabControl1.TabPages[0].Hide();
}
but it doesn't do anything so what can i do?
thank you for your cooperation
vishal jadav87 reputationPosted Jul 2, 2010, 11:57 PM EDT
Mesha23 reputationPosted Jul 3, 2010, 1:47 AM EDT
i will explain what i want to do ?
i have 2 forms (login form,main form)
the login form enters the user by the database. In other words, the data of log in is stored in database.
a certain tabpage does not appear to a certain user (by privileges).
thank you for your cooperation
Hiren SoniRank #694 · 3.5K reputationPosted Jul 3, 2010, 4:26 AM EDT
Form1 f1 = new Form1();
now when you create instance of Form1() , overload constructor of form1(bool flag)
now in login form: Form1 f1 = new Form1(true);
pass true if it is admin , false for employee.
and in form1_load event check the value is true or false, and hide/show tabpage.
if you like it, dont 4get to accept answer
Mesha23 reputationPosted Jul 3, 2010, 5:53 AM EDT
please Sir, if you don't mind could you explain to me what you mean because I didn't understand what you wrote
this is the code that i did.
private void Login_Enter_but_Click(object sender, EventArgs e)
{
this.m.connect.Open();
this.mycmd = "select User_name , Password from Users where User_name='" + Login_YourName_txt.Text + "' and Password='" + login_pass_txt.Text + "'";
this.command= new SqlCommand(this.mycmd,this.m.connect);
if (this.command.ExecuteScalar() != null)
{
this.mycmd = "select U_State from Users where User_name='" + Login_YourName_txt.Text + "' and Password='" + login_pass_txt.Text + "'";
this.command = new SqlCommand(this.mycmd, this.m.connect);
string num = this.command.ExecuteScalar().ToString();
if (num == "1")
{
this.Hide();
Interfaces f = new Interfaces();
f.Show();
//f.tabControl1.TabPages.Remove(tabPage1);
f.tabControl1.TabPages[0].Hide();
}
else
{
MessageBox.Show("You aren't actived","NotActive",MessageBoxButtons.OK,MessageBoxIcon.Stop);
}
}
else
{
MessageBox.Show("Sorry,your name or passwrod are wrong try agian", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Warning);
/* count++;
if (count >= 4)
{
this.Close();
count++;
}*/
}
m.connect.Close();
}
Muhammad ElBarawi12 reputationPosted Oct 17, 2015, 1:28 PM EDT