aardio 文档
aardio 范例:动态显示复选框
//动态显示复选框
import win.ui;
/*DSG{{*/
var winform = win.form(text="树形控件启用复选框:试试勾选有子节点的节点";right=471;bottom=497)
winform.add(
treeview={cls="treeview";left=19;top=17;right=453;bottom=480;asel=false;bgcolor=15793151;chkBox=1;db=1;dl=1;dt=1;edge=1;hscroll=1;infoTip=1;vscroll=1;z=1}
)
/*}}*/
/*
注意:请在窗口设计视图下,设置treeview控件的【显示复选框】为true
*/
//用户勾选、取消勾选复选框事件(状态图像变更事件)
winform.treeview.onStateImageChanging = function(hItem,checked,newImgIndex,oldImgIndex){
winform.text = ( checked ? "勾选 " : "取消勾选 " ) + winform.treeview.getItemText(hItem);
//遍历子节点
for hSubItem in winform.treeview.each(hItem){
winform.treeview.setItem(
stateMask = 0xF000/*_TVIS_STATEIMAGEMASK*/;
state = checked ? 0x1000 : 0; //动态显示或隐藏节点的复选框
hItem = hSubItem;
)
}
//展开子节点
winform.treeview.expand(hItem);
winform.treeview.setSelected(hItem);
}
//添加演示节点
var hitem = winform.treeview.insertItem( text="程序目录" );
var hSubItem = winform.treeview.insertItem( { text="子目录" },hitem/*父节点*/);
//添加演示节点
var hitem = winform.treeview.insertItem( {
text = "下面用一个数组指定子节点"; {
{ text = "子节点1" };
{ text = "子节点2" };
{ text = "下面用一个数组指定子节点"; {
"a";"b";"c";{ text = "d" }
}
};
}
} );
winform.show();
win.loopMessage();
Markdown 格式