得到一個窗體上的所有adotable,adoquery對象?

aderly 2004-07-27 09:05:37
我想做一個函數傳入窗體對象,然後把這個窗體上的所有adotable等控件的readonly設為false,這個功能怎麼做?請指教謝謝!!
...全文
70 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
risingsoft 2004-07-27
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);
function SetDSetReadOnly(var theForm: TForm; ReadOnly: boolean): Boolean;
var
i: integer;
begin
for i := 0 to theForm.ControlCount - 1 do
begin
if theForm.Controls[i] is TAdoTable then
(theForm.Controls[i] as TAdoTable).ReadOnly := ReadOnly;
if theForm.Controls[i] is TAdoQuery then
(theForm.Controls[i] as TAdoQuery).ReadOnly := ReadOnly;
end;
Result := ReadOnly;
end;
begin
SetDSetReadOnly(Form1,true);
end;
xiaolei_418 2004-07-27
  • 打赏
  • 举报
回复
var i:integer
begin
for i:=0 to Self.ComponentCount-1 do
begin
if Self.Components[i] is TadotableThen
begin
(Self.Components[i] as Tadotable).readonly:=False;
end;
end;
end;
juliens 2004-07-27
  • 打赏
  • 举报
回复
for i := 0 to ComponentCount - 1 do
begin
if Components[i] is TADOTable then
TADOTable(Components[i]).ReadOnly := False;
end;
zwjchina 2004-07-27
  • 打赏
  • 举报
回复
for i := 1 to Form.ComponentCount - 1
if Form.Component[i] is TadoTable then
TadoTable(Form.Component[i]).ReadOnly := False;
ln521 2004-07-27
  • 打赏
  • 举报
回复
(sender as Tadotable).readonly:= false;
zhlwyy 2004-07-27
  • 打赏
  • 举报
回复
为什么要那么麻烦
你直接选中所有的这些控件
他们的共同属性中就有这个选项
你把它false了不就可以了吗

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧