AntdUI.HyperlinkCheckbox 继承自 Checkbox,在复选框文本中支持 <a href=...>链接</a>,常用于“我已阅读并同意服务条款/隐私政策”等场景。
import win.ui;
import dotNet.AntdUI;
import System.Windows.Forms;
var winform = win.form(text="AntdUI HyperlinkCheckbox";right=660;bottom=220);
winform.add(
host={cls="custom";left=20;top=20;right=640;bottom=180;dl=1;dt=1;dr=1;db=1;z=1}
);
var chk = AntdUI.HyperlinkCheckbox(winform.host);
chk.Dock = System.Windows.Forms.DockStyle.Top;
chk.Height = 46;
chk.Text = "我已阅读并同意 <a href=terms>服务条款</a> 与 <a href=privacy>隐私政策</a>";
chk.Checked = false;
chk.LinkAutoNavigation = false;
chk.LinkClicked = function(sender,e){
winform.msgbox("打开协议:" + e.Href);
}
chk.CheckedChanged = function(sender,e){
// 这里处理勾选状态变化
}
winform.show();
win.loopMessage();
| 属性 | 说明 |
|---|---|
Text |
文本,可包含 <a href=...>...</a>。 |
Checked |
是否选中。 |
AutoCheck |
点击时是否自动切换选中状态。 |
LinkAutoNavigation |
是否自动调用默认浏览器打开链接。 |
NormalStyle / HoverStyle |
链接常规/悬停样式。 |
LinkPadding |
链接与周围字符间距。 |
ForeColor |
文本颜色。 |
chk.CheckedChanged = function(sender,e){
// 勾选状态改变
}
chk.LinkClicked = function(sender,e){
winform.msgbox("点击链接:" + e.Text + " / " + e.Href);
}
Checked、CheckedChanged、AutoCheck 等常用属性/事件。LinkAutoNavigation,在 LinkClicked 中打开自定义窗口或本地文档。