1、纯文本:
import win.ui;
import godking.vlistEx;
/*DSG{{*/
mainForm = win.form(text="vlistEx - table adapter";right=849;bottom=578)
mainForm.add(
vlist={cls="vlistEx";left=10;top=10;right=840;bottom=570;db=1;dl=1;dr=1;dt=1;edge=1;transparent=1;z=1}
)
/*}}*/
mainForm.show();
var t = { fields={"序号","姓名","年龄","地址","身份证"} };
for(i=1;10000;1){
var tt={};
tt["序号"]="[@rowindex]"; // 行序号标记是不允许编辑修改的
tt["姓名"]="["+string.random(math.random(1,10))+"]";
tt["年龄"]="["+string.random(math.random(1,20))+"]";
tt["地址"]="["+string.random(math.random(1,30))+"]";
tt["身份证"]="["+string.random(math.random(1,40))+"]";
..table.push(t,tt);
}
mainForm.vlist.setTable(t);
mainForm.vlist.setColWidthFit();
win.loopMessage();
2、带图片:
import win.ui;
import godking.vlistEx;
/*DSG{{*/
mainForm = win.form(text="vlistEx - table adapter";right=591;bottom=439)
mainForm.add(
listview={cls="vlistEx";left=10;top=10;right=576;bottom=432;acceptfiles=1;aw=1;db=1;dl=1;dr=1;dt=1;hscroll=1;vscroll=1;z=1}
)
/*}}*/
mainForm.show();
import inet.http
var img = inet.http.get("https://img-blog.csdnimg.cn/21d6c09c237442a08ab0a110d9bd8d12.png?x-oss-process=image/resize,m_fixed,h_224,w_224");
mainForm.listview.addImg("icon",img);
mainForm.listview.setRowHeight(80);
var t = {}
for(i=1;100;1){
..table.push(t,{"[@rowindex]",
"文本<img name='icon',w=20,h=20,scale=true>图片<img name='icon',w=20,h=20,scale=true>混合排版",
"<img name='icon',full=true>图片填满单元格",
"<img name='icon',full=true,scale=true>",
"<img name='icon',x=0,y=0,w=20,h=20><img name='icon',x=-20,y=0,w=20,h=20><img name='icon',x=0,y=-20,w=20,h=20><img name='icon',x=-20,y=-20,w=20,h=20>图片定点放置",
})
}
mainForm.listview.setTable(t,{"编号","混合排版","填满单元格","居中缩放","定点绘制"}/*列标题*/,/*列宽*/,1/*对齐方式*/,/*字典转为数组*/,/*字符串转为Utf8*/,/*是否克隆新表*/)
mainForm.listview.setColWidthFit();
win.loopMessage();
3、不同的表头字体:
import win.ui;
import godking.vlistEx;
/*DSG{{*/
mainForm = win.form(text="vlistEx - table adapter";right=849;bottom=578)
mainForm.add(
vlist={cls="vlistEx";left=10;top=10;right=840;bottom=570;db=1;dl=1;dr=1;dt=1;edge=1;transparent=1;z=1}
)
/*}}*/
var t = { fields={"序号","我的姓名","年龄","地址","身份证"} };
for(i=1;10;1){
var tt={};
tt["序号"]="[@rowindex]"; // 行序号标记是不允许编辑修改的
tt["我的姓名"]=math.random(1000,9999)+"姓名";
tt["年龄"]=math.random(10,99);
tt["地址"]=math.random(1,9999999)+"这里是超长文本地址";
tt["身份证"]=math.random(1000,9999)+"身份证";
..table.push(t,tt);
}
mainForm.vlist.setTable(t,,,1);
mainForm.vlist.headerBkcolor = {0xFF0000,0x00FF00,0xFFFFFF,0x0000FF}; // 单独设置表头各列背景颜色
mainForm.vlist.headerFont = { // 没有设置默认字体
::LOGFONT(name="宋体";point=12;color=0xFFFFFF); //单独设置某列字体
::LOGFONT(name="微软雅黑";point=18;color=0xFF0000); //单独设置某列字体
::LOGFONT(name="仿宋";point=22;bold=1;color=0x0000FF); //单独设置某列字体
[5]=::LOGFONT(name="仿宋";point=40;bold=1;color=0x0000FF); //单独设置某列字体
}
mainForm.show();
mainForm.vlist.setColWidthFit();
win.loopMessage();