虚表 —— 自定义数据适配器

import win.ui;
import godking.vlistEx
/*DSG{{*/
var winform = win.form(text="aardio form";right=749;bottom=699)
winform.add(
button={cls="button";text="上一页";left=190;top=620;right=300;bottom=670;z=2};
button2={cls="button";text="下一页";left=400;top=620;right=510;bottom=670;z=3};
vlistEx={cls="vlistEx";text="自定义控件";left=10;top=10;right=750;bottom=610;z=1}
)
/*}}*/
 
winform.show();
winform.vlistEx.setColumns({"编号","语文","数学"},{250,250,-1}/*列宽*/,/*格式*/)
var page = 1;
var c = winform.vlistEx.setCustomAdapter(21,function(row,col){
        if row==21 {
            if col == 1 return "平均分:";
            if col == 2 return "语文平均分:89";
            if col == 3 return "数学平均分:98";
        } else {
            var currow = (page-1)*20+row;
            if col = 1 return "NO.:"++currow; 
            return ..math.random(30,100); // 读取并返回单元格数据。这里用随机数代替。
        }
    })
winform.button.oncommand = function(id,event){
    if page>1 {
        page--;
        c.update();
    }
}
winform.button2.oncommand = function(id,event){
    page++;
    c.update();
}
win.loopMessage();