光庆大佬虚表的列线随意隐藏与显示
需求是我提的,代码是光庆大佬写的,面向大佬编程:lol原教程代码:
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;100;1){
var tt={};
tt["序号"]="[@rowindex]";// 行序号标记是不允许编辑修改的
tt["姓名"]="群众";
tt["年龄"]="团员";
tt["地址"]=
"党员";
tt["身份证"]=math.random(1000,9999)+"身份证";
..table.push(t,tt);
}
mainForm.vlist.setTable(t,{"序号","","政治面貌","","身份证"} ,{80,60,60,60,200},0x1);
mainForm.vlist.hideLineV = {2,3}
mainForm.vlist.onClick = function(row/*行*/,col/*列*/,x,y){
/*鼠标左键点击项目事件。x、y为鼠标相对于虚表的坐标*/
if col==2 or col==3 or col==4 {
mainForm.vlist.setCellColor(row,2,,null);
mainForm.vlist.setCellColor(row,3,,null);
mainForm.vlist.setCellColor(row,4,,null);
mainForm.vlist.setCellColor(row,col,,({0,0xAAAAFF,0xFFAAAA,0xAAFFAA}));
mainForm.vlist.redraw();
}
}
mainForm.show();
win.loopMessage();
修改后的代码:
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;100;1){
var tt={};
tt["序号"]="[@rowindex]";// 行序号标记是不允许编辑修改的
tt["姓名"]="群众";
tt["年龄"]="团员";
tt["地址"]="党员";
tt["身份证"]=math.random(1000,9999)+"身份证";
..table.push(t,tt);
}
mainForm.vlist.setTable(t,{"序号","","政治面貌","","身份证"} ,{80,60,60,60,200},0x1);
mainForm.vlist.hideLineV = {2,3}
mainForm.vlist.onClick = function(row/*行*/,col/*列*/,x,y){
/*鼠标左键点击项目事件。x、y为鼠标相对于虚表的坐标*/
if col==2 or col==3 or col==4 {
mainForm.vlist.setCellColor(row,2,,null);
mainForm.vlist.setCellColor(row,3,,null);
mainForm.vlist.setCellColor(row,4,,null);
mainForm.vlist.setCellColor(row,col,,({0,0xAAAAFF,0xFFAAAA,0xAAFFAA}));
mainForm.vlist.redraw();
}
}
mainForm.vlist.onDrawCellBg = function(row,col,hdc,rc,bkcolor,text){
/*绘制单元格背景,返回ture则忽略原背景,否则继续绘制原背景。注意:该背景包含padding部分,而padding以外的部分会被有效区域背景遮盖*/
if col==2 or col==3{
gdi.selectPen(
function(hdc,pen){
gdi.drawLine(hdc,rc.right,rc.top,rc.right,rc.bottom)
},hdc,0x0000FF,0x000000)
}
return true;
}
mainForm.show();
win.loopMessage();
效果对比:
页:
[1]