将文本框信息发送到组合框 [英] send textbox information to combobox

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

问题描述

我在form1中有一个文本框.

我想将文本框(在form1中)的信息发送到form2中的组合框.
我该怎么办?

请帮助我.

I have a textbox in form1.

I want to send the information of textbox(in form1) to combobox in form2.
How can I do this?

Help me please.

推荐答案

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

Google [
Passing Data Between Forms[^]

Google[^] it for more information.


嗅"?不用哭...:laugh:

如何执行将取决于显示Form2的操作:如果按下一个按钮,该按钮显示Form2的新实例,并且要从Form1中的TextBox向ComboBox添加数据,则有两种方法:

1)将文本传递给From2构造函数
"Sniff"? No need to cry... :laugh:

How you do it will depend on what you are doing to show Form2: if you are pressing a button, which shows a new instance of Form2 and you want to add data to the ComboBox from the TextBox in Form1, then there are two ways:

1) Pass the text to the From2 constructor
public Form2(string text)
   {
   myComboBox.Items.Add(text); // Or whatever you want to do with it
   {


Form2 f = new Form2(myTextBox.Text);
f.ShowDialog();



2)将文本传递给Form2中的属性.



2) Pass the text to a property in Form2.

public class Form2 : Form
   {
   public string DataForMyComboBox
      {
      set
         {
         myComboBox.Items.Add(value); // Or whatever you want to do with it
         }
   }


Form2 f = new Form2(myTextBox.Text);
f.DataForMyComboBox = myTextBox.Text;
f.ShowDialog();


如果那不是您在做什么,那么请解释您在做什么!


If that isn''t what you are doing, then explain what you are doing!


谢谢亲爱的
现在我是世界之巅.
thank u dear
now i''m the top of the world.


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

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