import win.ui;import console;
/*DSG{{*/
var winform = win.form(text="aardio form";right=759;bottom=479)
winform.add(
buttonEnd={cls="button";text="末页";left=572;top=442;right=643;bottom=473;z=6};
buttonFirst={cls="button";text="首页";left=216;top=442;right=287;bottom=473;z=5};
buttonNext={cls="button";text="下页";left=453;top=442;right=524;bottom=473;z=3};
buttonUp={cls="button";text="上页";left=335;top=442;right=406;bottom=473;z=2};
listview={cls="listview";left=83;top=33;right=669;bottom=438;ah=1;aw=1;dt=1;edge=1;fullRow=1;z=1};
staticPage={cls="static";text="第1页";left=88;top=445;right=183;bottom=462;transparent=1;z=4};
staticTitle={cls="static";text="数据表分页实例";left=81;top=1;right=261;bottom=33;font=LOGFONT(h=-24;name='微软雅黑');transparent=1;z=7}
)
/*}}*/
//listview数据表简单分页练习
//数据表
var dataTable = {};
dataTable['fields'] = {'a','b','c','d','e'};
for(i=1;1000;1) table.push(dataTable,{a="a"++i,b="b"++i,c="c"++i,d="d"++i,e="e"++i})
//分页参数
var pageNo,pageLine = 1,20;
var pageNum = math.floor(#dataTable/pageLine)+(#dataTable%pageLine>0?1:0)
//分页数据处理
winform.page = function(){
winform.listview.clear();
winform.staticPage.text = "共"++pageNum++"页,第"++pageNo++"页";
winform.listview.setColumns(dataTable.fields)
for(i=1;pageLine;1){
var pi = (pageNo-1)*pageLine+i;
if dataTable[pi]{
var tab = {};
for k,v in dataTable.fields table.push(tab,dataTable[pi][v]);
winform.listview.addItem(tab); //数组
}
}
}
winform.page(); //预显示
//首页
winform.buttonFirst.oncommand = function(id,event){
pageNo=1;
winform.page(); //分页显示
}
//上页
winform.buttonUp.oncommand = function(id,event){
if pageNo>1 pageNo--;
winform.page();//分页显示
}
//下一页
winform.buttonNext.oncommand = function(id,event){
if pageNo<pageNum pageNo++;
winform.page();//分页显示
}
//末页
winform.buttonEnd.oncommand = function(id,event){
pageNo=pageNum;
winform.page();//分页显示
}
//点击消息回调
winform.listview.wndproc = function(hwnd,message,wParam,lParam){
select(message) {
case 0x201/*_WM_LBUTTONDOWN*/{
var r,c=winform.listview.hitTest();//获取鼠标所在行列号
var text=winform.listview.getItemText(r,c)//获取单元格文本
win.msgbox(text);
}
}
//无返回值则继续调用默认回调函数
}
winform.show();
win.loopMessage();
简单练习