虚表 —— 自适应列宽

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();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

卢光庆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值