发送带有对象焦点的文本 [英] send Text with Object Focus
本文介绍了发送带有对象焦点的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
focus =textbox1.text; ???
我想用焦点填充对象吗?
I want to fill an object with focus?
推荐答案
这是一种很棒的方法-您不应该模拟这样的Tab键.您应该做的是创建一个包含要设置文本的文本框的List<TextBox>
,然后循环遍历该文本框.例如
This is an aweful way of doing it - you should not simulate tab keys like this. What you should do is create aList<TextBox>
containing the TextBoxes you wish to set the text of then loop through that. E.g.
List<TextBox> MyTextBoxes = new List<TextBox>();
MyTextBoxes.Add(textbox1);
//Add the other boxes here
string strnew = "hello";
int j = (int)Random.Next(0, MyTextBoxes.length);
for(int i = 0; i <= j; i++)
{
MyTextBoxes[i].Text = strnew;
}
希望这会有所帮助,
Ed
Hope this helps,
Ed
如果要更改表单中的文本框文本,请执行以下操作:
if you want to change the text of textBoxes in your form:
public void Form_Load(
{
foreach (Control control in this.Controls)
{
if (control is TextBox)
(control as TextBox).GotFocus += delegate(object sender, EventArgs e)
{
(control as TextBox).Text = "hello";
}
}
}
大家好,请帮助我编写代码:
hi all, help me in code:
for (int i = 0; i <= 5; i++)
{
SendKeys.Send("{tab}");
}
this.ActiveControl.Text = "hello"; ??????
this.ActiveControl.Select();
将字符串"hello"粘贴到焦点位置?
paste string "hello" in focused?
这篇关于发送带有对象焦点的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文