应该怎么写呢?(30分)

3

3368aa

Unregistered / Unconfirmed
GUEST, unregistred user!
我想让窗体上的所有数据感应控件的属性设为readonly,
for i:=0 to controlcount-1 do
begin
if ??????????????? then //这里应该怎么写,判断这个控件是否有readonly属性?
controls.readonly:=true;  //这里这么写对吗?
end;

深度历险上有一段,但我试了,不行,请高手赐教?
 
for i:=0 to controlcount-1 do
begin
try
controls.readonly:=true;
except
end;
end;

编译完以后,双击exe 文件执行看效果。
如果选中了 Integrated Debugging ,在IDE 中还会提示异常!
 
jsxjd:
你说的方法不行,controls看不到readonly属性的
 
for i:=1 to controlcount-1 do
begin
if (controls is TDBEdit) then
begin
(controls as Tdbedit).readonly:=true;
end
else if (controls is TDBCheckBox) then
begin
(controls as Tdbcheckbox).readonly:=true;
end;
...... (此处可根据实际情况添加其它类型判断)
end;
 
给你个提示吧,我想应该行的,只是自己比较懒,其实与thinknet的做法也类似,即,
用类名,数据感知控件一般会有相同的类名前缀,如,TDB,WW……什么的!
 
组件的只读属性的设置是在对数据成员的操作中只设了Read而没有Write
 
delphi深度历险  上有这么一段,我试了,但对Developer Express这个第三方控件不
起作用

var
i:integer;
prorpinfo:ppropinfo;
begin
fro i:=0 to componentcount=1 do
begin
propinfo:=getpropinfo(components.classinfo,'color');
if propinfo<>nil then
setordprop(components,propinfo,clred);
end;
end;

如果控件有color属性,程序动态改变全部控件的clolr属性为clred

请大家帮忙呀!!!
 
多人接受答案了。
 
顶部