在c#HELP中填充文本框 [英] populating a textbox in c# HELP
问题描述
hi guys
我正在创建一个带有Windows窗体的计算器。我不希望用户使用计算机键盘输入数据。所以我在表单上创建了许多按钮,供用户点击它们进入文本框输入数据。
如何使用数字填充文本框?
例如:
private void button1_Click( object sender,EventArgs e)
{
textBox1.Text = 7;
}
private void button2_Click( object sender,EventArgs e)
{
textBox1.Text = 8跨度>;
}
在上面的代码中,理想情况下,用户点击按钮1和按钮2然后文本框将是填充数字78
但似乎当我点击按钮1时,文本框中出现7这是一件好事,但当我点击按钮2时,7结束写的,变成8..有谁知道我如何填充文本框?
谢谢
Abz
你正在填充一个文本框!
重点是你每次都将文本设置为数字,什么你想做的是追加号码...试试这个
textBox1.Text + =7;
或textBox1.Text = textBox1.Text + 7\" 跨度>;
hi guys
i am creating a calculator with windows forms. I don't want users to enter data using the computer keyboard. So I have created a number of buttons on my form for the users to click them to enter into the textboxes for entering data.
How do i populate a textbox with numbers?
for example :
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "7";
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = "8";
}
in the above code, Ideally i wyd the user to click button 1 and button 2 then the textbox will be populated with the number "78"
but it seems when i click button 1 , "7" appears in the text box which is a good thing, but when i click button 2, "7" is over written and becomes "8".. does anyone know how i can populate a textbox?
Thank You
Abz
Well you are populating a textbox!
The point is you are setting the text to the number each time, what you want to do is append the number ... try this
textBox1.Text += "7";
ortextBox1.Text = textBox1.Text + "7";
这篇关于在c#HELP中填充文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!