这个很不错,推荐一下:
[AAuto] 纯文本查看 复制代码 import win.ui;
/*DSG{{*/
var winform = win.form(text="简码编程 jianma123.com";right=410;bottom=287)
winform.add(
button={cls="button";text="添加到树干1";left=259;top=37;right=375;bottom=66;z=2};
button2={cls="button";text="添加到树干2";left=259;top=71;right=375;bottom=100;z=3};
button3={cls="button";text="添加到树干3";left=259;top=105;right=375;bottom=134;z=4};
button4={cls="button";text="添加到选定项";left=259;top=140;right=375;bottom=169;z=6};
edit={cls="edit";left=18;top=209;right=385;bottom=268;edge=1;multiline=1;z=5};
treeview={cls="treeview";left=18;top=19;right=227;bottom=198;asel=false;bgcolor=16777215;edge=1;singleExpand=false;vscroll=1;z=1}
)
/*}}*/
var 树干1 = winform.treeview.insertItem( text="树干1" );
var 树干2 = winform.treeview.insertItem( text="树干2" );
var 树干3 = winform.treeview.insertItem( text="树干3" );
var i = 0;
//添加到树干1
winform.button.oncommand = function(id,event){
i = i+1;
var hSubItem = winform.treeview.insertItem( { text="树枝"+i },树干1);//添加树枝,指定父节点
winform.treeview.expand(树干1) //展开项
winform.treeview.redraw()//刷新
}
//添加到树干2
winform.button2.oncommand = function(id,event){
i = i+1;
var hSubItem = winform.treeview.insertItem( { text="树枝"+i },树干2);
winform.treeview.expand(树干2)
winform.treeview.redraw()
}
//添加到树干3
winform.button3.oncommand = function(id,event){
i = i+1;
var hSubItem = winform.treeview.insertItem( { text="树枝"+i },树干3);
winform.treeview.expand(树干3)
winform.treeview.redraw()
}
//添加到选定项
winform.button4.oncommand = function(id,event){
i = i+1;
var hSubItem = winform.treeview.insertItem( { text="树枝"+i },winform.treeview.getSelection());
winform.treeview.expand(winform.treeview.getSelection())
winform.treeview.redraw()
}
winform.treeview.onnotify = function(id,code,ptr){
if( code == 0xFFFFFFFE/*_NM_CLICK*/ ){
var hItem = winform.treeview.hitTest();//这样取的才是真正响应通知的节点
if( hItem ){
winform.edit.text="当前节点:"+winform.treeview.getItemText(hItem)+'\r\n';
winform.edit.print ( "路径:"+winform.treeview.getItemPath( hItem));
}
}
}
winform.show()
win.loopMessage();
|