这是一个使用多种表单的程序。
当我按下更新分数按钮时,我得到一个完全不同的表格,称为分数。
但是,一旦我输入了名称和分数,按OK后就会出现更新score
表格。
是否有任何方法可以仅将更新score
表单作为其独立表单,而不必通过score
表单?
更新score
格式:
public UppDateScore()
{
InitializeComponent();
score link = new score();
DialogResult bUpdate = link.ShowDialog();
if (bUpdate == DialogResult.OK)
{
txtName.Text = link.tagName.ToString();
numberBox.Items.Add((string)link.Tagnumbers);
//TagNumbs2
numberBox.Items.Add((string)link.TagNumbs2);
// TagNumbers3
numberBox.Items.Add((string)link.TagNumbers3);
}
}
原始表格:
private void bUpdate_Click(object sender, EventArgs e)
{
UppDateScore update = new UppDateScore();
update.Show();
}
score
格式:
private void bClearScores_Click(object sender, EventArgs e)
{
txtName.Text = "";
txtScore.Text = "";
txtStoreScores.Text = "";
}
private void bOk_Click(object sender, EventArgs e)
{
string name = txtName.Text;
int score = Convert.ToInt32(txtScore.Text);
int amount = list[0]+ list[1]+list[2];
string test = null;
test = amount.ToString();
string msg = null;
msg = name;
//just get the name
string theName = null;
theName = name;
// just get the numbers you typed in
// first number
string aNumber = null;
int theNumbers1 = list[0];
aNumber = theNumbers1.ToString();
// sencend number
string theNumber2 = null;
int theNumbers2 = list[1];
theNumber2 = theNumbers2.ToString();
// third number
string theNumber3 = null;
int theNumbers3 = list[2];
theNumber3 = theNumbers3.ToString();
// get the amount in the list
string amountSize = null;
int scoreSize = list.Count;
amountSize = scoreSize.ToString();
// get the avarage
int avarge = amount / scoreSize;
string theAvarge = null;
theAvarge = avarge.ToString();
foreach (int s in list) {
msg += " | " + s.ToString();
}