這是一個簡單的應用程序,應該保留學生信息的記錄。在表單上有用於提供姓名,課程等信息的文本框以及三個按鈕「SET」,「CLEAR」和「GET」。設置按鈕應該將用戶輸入並將其存儲爲字符串,CLEAR按鈕清除所有文本框,並且GET按鈕應該將數據帶回到文本框中。如何從文本框中存儲字符串,然後在C#中使用該字符串
namespace Project1
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public void SetBttn_Click(object sender, RoutedEventArgs e)
{
string firstname = FirstNameTxtBox.Text;
string lastname = LastNameTxtBox.Text;
string course = CourseTxtBox.Text;
string mno = MNoTxtBox.Text;
string yrmark = YrMarkTxtBox.Text;
}
private void ClrBttn_Click(object sender, RoutedEventArgs e)
{
FirstNameTxtBox.Text = String.Empty;
LastNameTxtBox.Text = String.Empty;
CourseTxtBox.Text = String.Empty;
MNoTxtBox.Text = String.Empty;
YrMarkTxtBox.Text = String.Empty;
}
private void GetBttn_Click(object sender, RoutedEventArgs e)
{
FirstNameTxtBox.Text = firstname;
LastNameTxtBox.Text = lastname;
CourseTxtBox.Text = course;
MNoTxtBox.Text = mno;
YrMarkTxtBox.Text = yrmark;
}
private void ShowBttn_Click(object sender, RoutedEventArgs e)
{
{
phd newWin = new phd();
newWin.Show();
}
}
}
}
也請發表你所得到的錯誤。 – Chris