C# Text don't display on another form after double clicking an item in listbox

后端 未结 3 1913
滥情空心
滥情空心 2020-12-21 18:40

I\'m doing a winform which consist a listbox (listbox10) with some items on it. When I doubleclick an item, it will show another form (Form3) which consist a textbox (textbo

3条回答
  •  再見小時候
    2020-12-21 18:48

    This is how you can access the member of the other form.

    msgForm3 = new Form3();
    msgForm3.textBox1.Text = listBox10.SelectedItem.ToString();
    msgForm3.Show();
    

    EDIT:

    From the Form3.Designer.cs file just change protection level from private to public.

    Replace

    private System.Windows.Forms.TextBox textBox1;
    

    To

    public System.Windows.Forms.TextBox textBox1;
    

提交回复
热议问题