vault backup: 2025-09-10 22:45:42
This commit is contained in:
@ -875,8 +875,62 @@ end.
|
||||
|
||||
### 配合在页面显示时隐藏或显示
|
||||
|
||||
```
|
||||
|
||||
|
||||
```delphi
|
||||
uses MyClass,Variables,BaseUtil,CommonFunc,DataConst,CFFrm,CFSimplePropFrm,Forms,StdCtrls,Variants,SysUtils,Classes,Controls,Dialogs,CHostIntf,ProductClas,DocClas,LoginClas,VirtualTrees,CEntClas,PathClas,cxRadioGroup;
|
||||
var
|
||||
i: Integer;
|
||||
j: Integer;
|
||||
n: Integer;
|
||||
frm: TForm;
|
||||
scb: TScrollBox;
|
||||
rdg: TcxRadioGroup;
|
||||
ctrl: TControl;
|
||||
gb: TGroupBox;
|
||||
rdgName: string;
|
||||
hidPnlNames: TStringList;
|
||||
begin
|
||||
rdgName := 'rdgrpmuf_1'; // 单选框组件名
|
||||
hidPnlNames := TStringList.Create;
|
||||
try
|
||||
hidPnlNames.Add('gbcxtsCusPage_1'); // 添加要隐藏的容器名
|
||||
hidPnlNames.Add('gbcxtsCusPage_2'); // 可以多个
|
||||
for i := 0 to Screen.FormCount - 1 do
|
||||
begin
|
||||
frm := Screen.Forms[i];
|
||||
if Pos('CFFormSheetPropForm', frm.Name) = 1 then begin //找到了窗口
|
||||
rdg := TcxRadioGroup(frm.FindComponent(rdgName));
|
||||
if Assigned(rdg) then begin // 找到了单选框
|
||||
scb := rdg.Parent as TScrollBox; // 遍历父容器
|
||||
for j := 0 to scb.ControlCount - 1 do
|
||||
begin
|
||||
ctrl := scb.Controls[j];
|
||||
if hidPnlNames.IndexOf(ctrl.Name)>-1 then begin
|
||||
if rdg.itemindex = 0 then begin
|
||||
ctrl.visible := false;
|
||||
end;
|
||||
end else begin // 不是想要的控件
|
||||
if ctrl is TGroupBox then begin // 如果是分组框,再遍历子件
|
||||
gb := ctrl as TGroupBox;
|
||||
for n := 0 to gb.ControlCount - 1 do begin
|
||||
ctrl := gb.Controls[n];
|
||||
if hidPnlNames.IndexOf(ctrl.Name)>-1 then begin
|
||||
if rdg.itemindex = 0 then begin
|
||||
ctrl.visible := false;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
hidPnlNames.Free;
|
||||
end;
|
||||
end.
|
||||
```
|
||||
|
||||
### 说明
|
||||
|
Reference in New Issue
Block a user