如何将一个表单的comboBox selectedItem转换为另一个表单

如何将一个表单的comboBox selectedItem转换为另一个表单

问题描述:





如何将表格中选定的combox项目转换为另一种形式。(connect和Form1)



连接形式:





How to get the selected item of combox in form to another form.(connect and Form1 )

in connect form :

<pre lang="c#"><pre lang="sql">public string machineId
        {
            get
            {
                return comboBox1.SelectedItem.ToString();
            }
            set
            {
                comboBox1.Text = value;
            }
        }</pre></pre>

and in Form1;

<pre lang="c#"><pre lang="c#">
                Connect c = new Connect();
                String machineid=c.machineId;





所以我得到错误:at String machineid = c.machineId



对象引用未设置为对象的实例。



so i got the error as:at String machineid=c.machineId

Object reference not set to an instance of an object.

您好,这篇文章描述了用于在页面之间传递值的diffrents技术。





在表单之间传递数据 [ ^ ]

b $ b



希望有所帮助
Hi, here is an article that describes the diffrents techniques used to pass values between pages.


Passing Data Between Forms[^]



Hope it helps