问题描述
是否可以遍历所有控件集合并将
文本框单独作为只读。我没有看到
控件的只读属性在这种情况下,有人可以帮助我吗?
我想在下面做这样的事情。但是我得到一条消息Readonly不是
有效财产。
foreach(控制ctl in pnlBenefits.Controls)
{
if(ctl is TextBox)
ctl.ReadOnly = false;
}
foreach(控制ctl in pnlBenefits.Controls)
{
if(ctl is TextBox)
{
TextBox txt =(TextBox)ctl;
txt.ReadOnly = false;
}
}
-----
John Saunders
Is it possible to iterate through all the controls collection and make the
textboxes alone as read only.I don''t see a readonly property for the
Control.Can some one help me in this context?
I want to do something like this below.But I get a message Readonly is not
valid property.
foreach (Control ctl in pnlBenefits.Controls)
{
if (ctl is TextBox)
ctl.ReadOnly=false;
}
foreach (Control ctl in pnlBenefits.Controls)
{
if (ctl is TextBox)
{
TextBox txt = (TextBox) ctl;
txt.ReadOnly=false;
}
}
-----
John Saunders
这篇关于使用控件Collection进行只读控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!