将组合框值加载到标签 [英] load combobox values to lables
本文介绍了将组合框值加载到标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在form1中有组合框,我需要将组合框值加载到另一个名为form2
的形式中
谁能帮我做到这一点?
我尝试过这样,但很困惑
HI GUYS,
I have combobox in form1 and I need to load combobox values to another form called form2
Can anyone help me to do this?
I tried like this but confused
public string LabelText
{
get
{
return this.lblFO.Text;
}
set
{
this.lblFO1.Text = value;
}
}
form2 frm2 = new form2();
frm2.lblFO = this.cmbFO.valuemember;
谢谢
Thank you
推荐答案
如果需要获取所选项目的值,请使用SelectedValue
useSelectedValue
if you need to get the value of the selected item
form2 frm2 = new form2();
frm2.LabelText = this.cmbFO.SelectedValue.ToString();
首先将form2组合框设为公开它的属性
之后,在您想要的事件中编写此代码
然后创建form2对象
form2 obj = new form2();
obj.Label1.text = combobox1.SelectedValue.ToString();
我认为它将起作用.
First make form2 combobox as public from its property
after that write this code in which event you want
then create object of form2
form2 obj =new form2();
obj.Label1.text=combobox1.SelectedValue.ToString();
I think it will work.
有多种方法可以在表单之间传递值,请参考: ^ ]
There are a number of ways to pass value between forms, refer: Passing Data Between Forms[^]
这篇关于将组合框值加载到标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文