从TextBox提取数据 [英] Fetching data from a TextBox

查看:98
本文介绍了从TextBox提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Button.Click事件之后将数据从TextBox提取到ComboBox.

I want to fetch data from TextBox to a ComboBox after Button.Click event.

推荐答案

示例:

Example:

private void button1_Click(object sender, EventArgs e)
        {
            comboBox1.Items.Add(txtName.Text);
        }




如果有帮助,请投票并接受答案.




Please vote and Accept Answer if it Helped.


处理按钮Click事件,并使用:
Handle the button Click event, and use:
myComboBox.Items.Add(myTextBox.Text);


这是一件非常基本的事情,我怀疑您是一般编程还是至少C#的新手.
考虑到这一点,我不会对您太苛刻,但是如果有人给您解决方案,您将永远不会成为程序员.

您的任务可以分为两部分
1)获取TextBox
的内容 2)将项目添加到ComboBox


使用这两个作为搜索短语,然后尝试将找到的内容放到一些代码中.

尝试后,如果仍然遇到问题,请再次询问以显示所使用的代码并清楚地说明问题.
This is such an elementary thing to do that I suspect you are new to either programming in general or at least to C#.

Bearing this in mind I will not be too hard on you but if anyone gives you the solution you will never become a programmer.

Your task can be divided into two parts
1) Getting the contents of a TextBox
2) Adding an item to a ComboBox


Use those two as search phrases and then try to put what you find together into some code.

Once you have tried and if you are still stuck, ask again showing the code you used and explaining the problem clearly.


这篇关于从TextBox提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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