在C#中的表单应用程序中找到文本框
问题描述:
我想以一般功能(如
)的形式找到文本框
和文本框,如
txtbarcode1
txtbarcode2
txtbarcode3
txtbarcode4
txtbarcode5
txtbarcode6
I want to find textbox in form in general function like
and textbox like
txtbarcode1
txtbarcode2
txtbarcode3
txtbarcode4
txtbarcode5
txtbarcode6
private void lookControl()
{
for(int i=1;1<=12;i++)
{
//// find control here with ("txtbarcode"+i) ////
}
}
如果有的话请给我发代码
谢谢
Mohit
if anyway plz send me code
thanks you
Mohit
答
有一个代码:
There is a code:
public void LookControl()
{
foreach (Control control in this.Controls)
{
if (control is TextBox)
// You can check any other property here and do what you want
// for example:
if ((control as TextBox).Text == string.Empty)
;//Action
}
}
让我知道您是否还有其他想法.
Let me know if there is something else in your mind.
应该是工作人员
it should be Work guys
public void LookControl()
{
for (int i = 1; i <=12; i++)
{
MessageBox.Show(((TextBox)(this.Controls[("txtbarcode" + i.ToString())])).Text);
}
}
问候
sarva
regards
sarva
private void lookControl()
{
for(int i=1;i<=12;i++)
{
//// find control here with ("txtbarcode"+i) ////
Directcast(this.controls.find("txtbarcode" + i.ToString(),True).getvalue[0],Textbox).Text="";
}
}
祝您编码愉快!
:)
Happy Coding!
:)