//编辑树形控件
import win.ui;
/*DSG{{*/
var winform = win.form( bottom=249;parent=...;right=349;text="树形控件编辑项文本 演示" )
winform.add( 
btnSelectAll={ bottom=232;right=271;left=172;top=206;z=2;text="编辑选定项";cls="button" };
treeview={ asel=false;bgcolor=15793151;bottom=190;right=326;left=22;cls="treeview";top=17;style=256;z=1;editable=1;edge=1;exstyle=131072 }
)
/*}}*/

var hitem = winform.treeview.insertItem( text="程序目录" );
var hSubItem = winform.treeview.insertItem( { text="子目录" },hitem/*父节点*/);

winform.treeview.onnotify = function(id,code,ptr){
	 if(code =0xFFFFFE66/*_TVN_BEGINLABELEDITA*/ ){  
	 	return false; //允许编辑项
	 }
	 if( code == 0xFFFFFE65/*_TVN_ENDLABELEDITA*/ ){
	 	var dispInfo = winform.treeview.getNotifyDispInfo(code,ptr)
	 	if( dispInfo ? dispInfo.item ) {
	 		winform.treeview.setItemText( dispInfo.item.hItem, dispInfo.item.text ) ;
	 	}
	 } 
}

hitem = winform.treeview.insertItem( { 
        text = "children数组指定子节点"; 
        children = { 
            { text = "子节点"  };
            { text = "子节点2" };
        }
} ) 
  
winform.btnSelectAll.oncommand = function(id,event){  
	winform.treeview.editLable( winform.treeview.getSelection() ) 
} 
	
winform.show() 
win.loopMessage();

 

