虚表 —— 自绘单元格背景,模拟按钮效果

光庆 1月前 320

import win.ui;
import godking.vlistEx;
/*DSG{{*/
mainForm = win.form(text="vlistEx - table adapter";right=807;bottom=319;border="thin")
mainForm.add(
button={cls="button";text="Button";left=352;top=264;right=464;bottom=304;z=2};
listview={cls="vlistEx";left=16;top=24;right=792;bottom=240;acceptfiles=1;aw=1;db=1;dl=1;dr=1;dt=1;edge=1;hscroll=1;vscroll=1;z=1}
)
/*}}*/
//======================= 创建虚表 =======================
mainForm.listview.setColumns({"序号","编","辑"},,1);
mainForm.listview.headerAlign = {1,2,0};
mainForm.listview.hideHeaderLineV =2;
var t = {
    {"[@rowindex]","修改","删除"} 
    {"[@rowindex]","修改","删除"} 
    {"[@rowindex]","修改","删除"} 
    {"[@rowindex]","修改","删除"} 
    {"[@rowindex]","修改","删除"} 
}
mainForm.listview.setTable(t,false);
//======================= 功能演示 =======================
mainForm.listview.onDrawCellRectBg = function(row,col,hdc,rc,bkcolor,text){
    if col==2 {..gdi.fillRect(topointer(hdc),0x5599EE,rc); return true;} 
    if col==3 {..gdi.fillRect(topointer(hdc),0xEE9955,rc); return true;} 
}
mainForm.listview.onClick = function(row/*行*/,col/*列*/,x,y){
    if col==2 ..win.msgbox("您要修改第"++row++"行吗?");
    if col==3 ..win.msgbox("您要删除第"++row++"行吗?");
}
mainForm.show();
win.loopMessage();


最新回复 (0)
返回