From 51a9a4bc716f7073665aea063514ace7facd8af6 Mon Sep 17 00:00:00 2001 From: LanHeron Date: Mon, 8 Sep 2025 10:57:44 +0800 Subject: [PATCH] vault backup: 2025-09-08 10:57:44 --- .../相关操作/4.0-other/999.Delphi脚本记录.md | 120 +++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md b/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md index 093249a7..6bb7d21d 100644 --- a/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md +++ b/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md @@ -877,7 +877,125 @@ end. 因为使用了 `Sender` 参数,所以这段脚本是只能绑定在控件上的,不能够绑定到 **事件脚本** 上 -控制窗体表单 +## 控制窗体表单明细表是否显示 + +和上一段对比,因为没有使用 `Sender` 参数,所以这个段脚本可以使用在 **事件脚本** 上 + +```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 + rdgrpmuf_9: TcxRadioGroup; // 声明单选框组变量 + i: Integer; + +begin + try + // 尝试查找并初始化单选框组组件 + // 这里假设rdgrpmuf_9是窗体上的一个组件,需要确保它已被正确创建和初始化 + if not Assigned(rdgrpmuf_9) then + begin + // 如果组件未分配,尝试从屏幕上的窗体中查找 + for i := 0 to Screen.FormCount - 1 do + begin + if Screen.Forms[i].FindComponent('rdgrpmuf_9') is TcxRadioGroup then + begin + rdgrpmuf_9 := TcxRadioGroup(Screen.Forms[i].FindComponent('rdgrpmuf_9')); + Break; + end; + end; + + // 如果仍然找不到组件,显示错误信息并退出 + if not Assigned(rdgrpmuf_9) then + begin + ShowMessage('找不到rdgrpmuf_9组件'); + Exit; + end; + end; + + // 根据选择的值显示对应的控件 + case rdgrpmuf_9.ItemIndex of + 0: // 选中第一项 + begin + gbcxtsCusPage_1.Visible := True; // 显示页面1 + gbcxtsCusPage_2.Visible := False; // 隐藏其他页面 + gbcxtsCusPage_3.Visible := False; + gbcxtsCusPage_4.Visible := False; + gbcxtsCusPage_5.Visible := False; + gbcxtsCusPage_6.Visible := False; + gbcxtsCusPage_7.Visible := False; + end; + 1: // 选中第二项 + begin + gbcxtsCusPage_1.Visible := False; + gbcxtsCusPage_2.Visible := True; + gbcxtsCusPage_3.Visible := False; + gbcxtsCusPage_4.Visible := False; + gbcxtsCusPage_5.Visible := False; + gbcxtsCusPage_6.Visible := False; + gbcxtsCusPage_7.Visible := False; + end; + 2: // 选中第三项 + begin + gbcxtsCusPage_1.Visible := False; + gbcxtsCusPage_2.Visible := False; + gbcxtsCusPage_3.Visible := True; + gbcxtsCusPage_4.Visible := False; + gbcxtsCusPage_5.Visible := False; + gbcxtsCusPage_6.Visible := False; + gbcxtsCusPage_7.Visible := False; + end; + 3: // 选中第四项 + begin + gbcxtsCusPage_1.Visible := False; + gbcxtsCusPage_2.Visible := False; + gbcxtsCusPage_3.Visible := False; + gbcxtsCusPage_4.Visible := True; + gbcxtsCusPage_5.Visible := False; + gbcxtsCusPage_6.Visible := False; + gbcxtsCusPage_7.Visible := False; + end; + 4: // 选中第五项 + begin + gbcxtsCusPage_1.Visible := False; + gbcxtsCusPage_2.Visible := False; + gbcxtsCusPage_3.Visible := False; + gbcxtsCusPage_4.Visible := False; + gbcxtsCusPage_5.Visible := True; + gbcxtsCusPage_6.Visible := False; + gbcxtsCusPage_7.Visible := False; + end; + 5: // 选中第六项 + begin + gbcxtsCusPage_1.Visible := False; + gbcxtsCusPage_2.Visible := False; + gbcxtsCusPage_3.Visible := False; + gbcxtsCusPage_4.Visible := False; + gbcxtsCusPage_5.Visible := False; + gbcxtsCusPage_6.Visible := True; + gbcxtsCusPage_7.Visible := False; + end; + 6: // 选中第七项 + begin + gbcxtsCusPage_1.Visible := False; + gbcxtsCusPage_2.Visible := False; + gbcxtsCusPage_3.Visible := False; + gbcxtsCusPage_4.Visible := False; + gbcxtsCusPage_5.Visible := False; + gbcxtsCusPage_6.Visible := False; + gbcxtsCusPage_7.Visible := True; + end; + end; + except + on E: Exception do + begin + // 显示具体的异常信息 + ShowMessage('发生错误: ' + E.Message); + end; + end; +end. +``` ## 从文档名称中获取文件编码