使用控件Collection进行只读控件 [英] Make a control Readonly using the controls Collection

查看:58
本文介绍了使用控件Collection进行只读控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以遍历所有控件集合并将

文本框单独作为只读。我没有看到

控件的只读属性在这种情况下,有人可以帮助我吗?

我想在下面做这样的事情。但是我得到一条消息Readonly不是

有效财产。

foreach(控制ctl in pnlBenefits.Controls)

{

if(ctl is TextBox)

ctl.ReadOnly = false;

}

解决方案

我相信你所追求的是:

..GetType()

-

Curt Christianson

所有者/首席开发人员,DF-Software

网站: http://www.Darkfalz.com

博客: http://blog.Darkfalz.com

" GP" ; < GP@discussions.microsoft.com>在消息中写道

新闻:C0 ********************************** @ microsof t.com ...

是否可以遍历所有控件集合并将
文本框单独设为只读。我没有看到我想在下面做这样的事情。但是我得到一条消息Readonly不是
有效的属性。
foreach(Control ctl in pnlBenefits.Controls)
{
if(ctl is TextBox)
ctl.ReadOnly = false;
}



为什么不进行明确的类型转换,然后获取其只读属性

foreach(控制ctl in pnlBenefits.Controls)

{

if(ctl is TextBox)

{

((TextBox)ctl).ReadOnly = false;

}

}


i认为这应该做的工作

-


问候,


Hermit Dave

http://hdave.blogspot.com

" ; GP" < GP@discussions.microsoft.com>在消息中写道

新闻:C0 ********************************** @ microsof t.com ...

是否可以遍历所有控件集合并将
文本框单独设为只读。我没有看到我想在下面做这样的事情。但是我得到一条消息Readonly不是
有效的属性。
foreach(Control ctl in pnlBenefits.Controls)
{
if(ctl is TextBox)
ctl.ReadOnly = false;
}



" GP" < GP@discussions.microsoft.com>在消息中写道

新闻:C0 ********************************** @ microsof t.com ...

是否可以遍历所有控件集合并将
文本框单独设为只读。我没有看到我想在下面做这样的事情。但是我得到一条消息Readonly不是
有效的财产。



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;
}

解决方案

I believe what you are after is:
..GetType()
--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"GP" <GP@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...

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;
}



why dont you do a explicit typecast and then get its readonly property
foreach (Control ctl in pnlBenefits.Controls)
{
if (ctl is TextBox)
{
((TextBox)ctl).ReadOnly = false;
}
}

i think this should do the job
--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"GP" <GP@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...

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;
}



"GP" <GP@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...

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)
{
TextBox txt = (TextBox) ctl;
txt.ReadOnly=false;
}
}
-----
John Saunders


这篇关于使用控件Collection进行只读控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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