本文整理汇总了C#中Control.Show方法的典型用法代码示例。如果您正苦于以下问题:C# Control.Show方法的具体用法?C# Control.Show怎么用?C# Control.Show使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Control
的用法示例。
在下文中一共展示了Control.Show方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnLogin_Click
private void btnLogin_Click(object sender, RoutedEventArgs e) //*****the function of login button*****
{
if (txtUsername.Text == "") //check if the username field is empty
{
MessageBox.Show("You have to enter your Matric number (username) to log in!");
return;
}
else if (passwordBox1.Password == "") //check if the password field is empty
{
MessageBox.Show("You have to enter your password to log in!");
return;
}
else
{
StreamReader SR;
string S;
SR = File.OpenText(@"students.txt"); //load data from 'students.txt' using StreamReader
S = SR.ReadLine();
while (S != null) //using the while loop to load data to the 3 lists
{
string[] words = S.Split(',');
if (words.Count() > 4)
{
nameList.Add(words[0]);
usernameList.Add(words[1]);
passwordList.Add(words[2]);
}
S = SR.ReadLine();
}
SR.Close();
bool check = false;
for (int i = 0; i < usernameList.Count(); i++)
{
if (txtUsername.Text == usernameList[i]) //to check if the username entered by the user exists in the data base
{
if (passwordBox1.Password == passwordList[i]) //the case which the password is correct
{
StreamWriter writer = new StreamWriter(@"matricNo.txt");
writer.WriteLine(usernameList[i]);
writer.Close();
StreamWriter writers = new StreamWriter(@"name.txt");
writers.WriteLine(nameList[i]);
writers.Close();
Control controlwindow = new Control();
controlwindow.Show();
controlwindow.labelwelcome.Content = nameList[i]+" (" + usernameList[i] +") ";
// MessageBox.Show("Welcome, " + nameList[i] + "!");
this.Close();
check = true;
return;
}
else if (passwordBox1.Password != passwordList[i]) //the case which the password is incorrect
{
MessageBox.Show("The password you entered is invalid. Please try again.");
check = true;
return;
}
}
}
if (check == false) //the case the username is not registered in the data base
{
MessageBox.Show("No such user! Please check again!");
}
}
}