组合框内容 [英] Combo box content

查看:68
本文介绍了组合框内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两种形式,即form1和2.

在form2中,我有一个名为cbxds的组合框. 在form1中,我有一个名为tbxname的文本框.
在form1中,我声明一个字符串并按如下方式存储名称:string name = tbxname.text;

我想将此字符串值分配给组合框.
我尝试了如下操作,但不起作用.

您的帮助很必要.

I have two forms, form1 and 2.

In form2 I have a combobox named cbxds.
In form1 I have a textbox named tbxname.

In form1 I declare a string and store the name as follows: string name = tbxname.text;

I want to assign this string value to the combobox.
I tried something as follows, but its not working.

Your help is needful.

form2 sec = new form2;
sec.cbxds.items.add(name);

推荐答案

问题是您创建form2new实例,而不是引用已打开的实例!
The problem is that you create a new instance of form2 instead of referencing the already opened instance!


cbxds.Items.Add(name);




没有这项工作的完整代码,很难看到.

请将其添加到原始问题.




Hard to see without your full code for this job.

Please add it to the original question.


这篇关于组合框内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆