Hello all, I want to know does anyone ever make some class or program as administrator to control menu strip object..?
Example, user "hello" with password "world" can only access certain menu on windows form application..
I don't have any idea how to do that.. thanks..
Loading
FroglegPosted Feb 1, 2012, 2:51 PM
namespace UserMenu
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
checkBox1.Checked = true;
disableButts();
}
public void disableButts()
{
bttn1.Enabled = false;
bttn2.Enabled = false;
bttn3.Enabled = false;
bttn4.Enabled = false;
bttn5.Enabled = false;
}
private void bttnCancel_Click(object sender, EventArgs e)
{
disableButts();
textBox1.Text = "";
textBox2.Text = "";
}
private void bttnOK_Click(object sender, EventArgs e)
{
if (textBox1.Text=="hello" && textBox2.Text=="world")
{
bttn1.Enabled = true;
bttn2.Enabled = false;
bttn3.Enabled = false;
bttn4.Enabled = true;
bttn5.Enabled = false;
}
else if (textBox1.Text == "ken" && textBox2.Text == "password")
{
bttn1.Enabled = false;
bttn2.Enabled = true;
bttn3.Enabled = false;
bttn4.Enabled = false;
bttn5.Enabled = true;
}
else
{
MessageBox.Show("Incorrect name and/or password");
}
}
private void bttnLogOff_Click(object sender, EventArgs e)
{
disableButts();
textBox1.Text = "";
textBox2.Text = "";
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
textBox2.PasswordChar = '*';
}
else
{
textBox2.PasswordChar = '\0';
}
}
}
}
Buttons 1 to 5 are your menu -you will need to store your passwords/usernames securely