//Listbox控件演示
////Listbox控件演示//button、Edit、Listbox控件使用演示

/************************************
Author		: xYe
Time		: March 26, 2010
Version		: 
Description : 
************************************/


import win;
import win.ui; 
import win.ui.menu
import win.ole.image
/*DSG{{*/
var winform = win.form(parent=...; bgcolor=14215660;bottom=171;right=397;text="button/listbox/edit控件演示";style=0;min=1;exmode="";title="AAuto Form" )
winform.add( 
edit={ bgcolor=16777215;bottom=44;color=0;right=360;left=129;multiline=1;top=20;acceptfiles=1;tabstop=1;text="请输入...";z=8;edge=1;cls="edit" };
static={ color=0;bgcolor=14215660;bottom=153;align="";right=360;left=128;transparent=1;top=111;acceptfiles=1;tabstop=1;text="";z=4;edge=1;cls="static" };
static2={ bgcolor=14215660;bottom=236;color=0;text="static2";left=196;align="";top=235;acceptfiles=1;transparent=1;right=197;tabstop=1;z=6;cls="static" };
btnFindEx={ bgcolor=14215660;bottom=107;color=0;right=362;left=298;multiline=1;top=83;acceptfiles=1;transparent=1;text="精确查找";tabstop=1;z=10;cls="button" };
btnClear={ bgcolor=16053492;bottom=76;color=0;text="清除";left=184;multiline=1;top=52;acceptfiles=1;z=2;right=230;transparent=1;tabstop=1;cls="button" };
btnAdd={ bgcolor=14215660;bottom=75;color=0;text="添加";left=126;multiline=1;top=51;acceptfiles=1;z=3;right=172;transparent=1;tabstop=1;cls="button" };
groupbox={ bgcolor=14215660;bottom=165;color=0;text="添加删除";left=114;top=2;acceptfiles=1;tabstop=1;z=0;right=379;edge=1;cls="groupbox" };
btnDelete={ bgcolor=14215660;bottom=76;color=0;text="删除";left=241;multiline=1;top=52;acceptfiles=1;z=1;right=287;transparent=1;tabstop=1;cls="button" };
btnFind={ bgcolor=14215660;bottom=76;color=0;right=360;left=297;multiline=1;top=52;acceptfiles=1;transparent=1;text="模糊查找";tabstop=1;z=9;cls="button" };
listbox={ z=5;bgcolor=16777215;bottom=144;color=0;text="listbox";left=3;top=3;
items={  };acceptfiles=1;tabstop=1;vscroll=1;right=110;edge=1;cls="listbox" };
combobox={ bottom=101;right=236;left=128;top=81;text="combobox";z=7;
items={  };mode="dropdown";edge=1;cls="combobox" }
)
/*}}*/

winform.btnFindEx.oncommand = function(id,event){
	var ind = winform.listbox.findEx(winform.edit.text)
	winform.listbox.selIndex = ind
	
	winform.combobox.selText = winform.edit.text
	win.msgbox(ind,"AAuto")
}//endproc


winform.btnFind.oncommand = function(id,event){ ;
	var ind = winform.listbox.find(winform.edit.text)
	winform.listbox.selIndex = ind
	
	var ind = winform.combobox.find(winform.edit.text)
	winform.combobox.selIndex = ind
	winform.msgbox(ind)
}//endproc
 
winform.combobox.oncommand = function(id,event){
	//win.msgbox( winform.combobox.text );
	winform.edit.text = winform.combobox.text
	
}//endproc

winform.btnClear.oncommand = function(id,event){
	winform.listbox.clear();
	winform.static.text = "";
	winform.redraw();
}//endproc

winform.listbox.oncommand = function(id,event){ 
		winform.redraw();
		winform.static.text =  string.format( '您选中了第%d项\n总计%d项\n项名：%s',winform.listbox.selIndex,winform.listbox.count,winform.listbox.text);
}//endproc

winform.btnDelete.oncommand = function(id,event){

	winform.listbox.delete(); 
	
}//endproc

winform.btnAdd.oncommand = function(id,event){
	str = winform.edit.text;
	winform.listbox.add(str)
	winform.combobox.add(str)
	winform.combobox.selText =  str 
	winform.listbox.selIndex = winform.listbox.count;
}//endproc

	
winform.show(true) 
win.loopMessage( winform );
