首页 > 解决方案 > 按下更新分数按钮时具有完全不同的表格

问题描述

这是一个使用多个表单的程序。

当我按下更新分数按钮时,我会得到一个完全不同的表格,称为分数。但是,一旦我输入名称和分数,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();
}

标签: c#winforms

解决方案


推荐阅读