无法将值传递给其他形式

时间:2019-01-11 11:20:26

标签: c#

filteredSymptoms的值是皮疹,咳嗽,腹泻,当将这些filteredSymptoms的值传递给另一种形式时,filteredSymptoms的值不会传递给form2(这是第二种形式)。我的代码的哪一部分是错误的或缺少某些内容?

Form1

FinalScreen showForm = new FinalScreen();
showForm.checkedSymptoms = filteredSymp;

Form2

public string checkedSymptoms { get; set; }
label1.Text = checkedSymptoms;

1 个答案:

答案 0 :(得分:0)

在FinalScreen上创建一个重载构造函数

    public FinalScreen()
    {
        InitializeComponent();
    }

    public FinalScreen(string checkedSymptoms)
        :base()
    {
        InitializeComponent();

        CheckedSymptoms = checkedSymptoms;
    }

    public string CheckedSymptoms { get; set; }

    private void FinalScreen_Load(object sender, EventArgs e)
    {
        label1.Text = CheckedSymptoms;
    }

然后

    FinalScreen showForm = new FinalScreen(filteredSymp);