演示GIF:
适用一些轻量的填表场景
代码:(需要最新的虚表库)
import win.ui;
import godking.vlistEx;
/*DSG{{*/
var winform = win.form(text="demo";right=1088;bottom=480;bgcolor=16777215;border="thin";mode="popup";title=1)
winform.add(
vlist1={cls="vlistEx";text="自定义控件";left=24;top=12;right=1049;bottom=372;bgcolor=16777215;border=1;z=1}
)
/*}}*/
tab1 ={"发生日期","发生部位";"切口愈合不良的主要事件";"采取措施";"二期缝合";"二期缝合时间";"预后";"愈合不良与预后的关系";"愈合不良主要原因"}
tab2 = {"","";"添加";"添加";"";"";"";"";"添加"}
//表头及第一行插入
winform.vlist1.headerBkcolor = 0xF89A1A
winform.vlist1.headerFont = ::LOGFONT(name="宋体";point=11;color=0xFFFFFF;bold = true )/*【属性】表头文本字体*/
winform.vlist1.setColumns(tab1,{100,100,180,90,90,110,60,170,150},1);
winform.vlist1.setHeaderHeight(50);
winform.vlist1.selectedBkColor = 0xFFFFFF;
winform.vlist1.insertRow(1,tab2);
winform.vlist1.setColumnType({5,7,8} ,1/*_vlistEx_ColType_ComboBox*/,true/*显示小箭头*/,0xAAAAAA/*箭头颜色*/ )
//开启单击编辑
winform.vlist1.editOnClick = true;
//按钮位置需要禁止编辑
winform.vlist1.onEditBegin = {false,3,4,9};
//下拉框
winform.vlist1.onComboBoxDropDown = function(comboBox,row,col){
/*下拉列表框即将弹出。参数:下拉列表框组件、虚表行号、虚表列号*/
select(col) {
case 5 {
comboBox.items={"是","否"};
}
case 7{
comboBox.items = {"治愈","好转","无变化","恶化","死亡"};
}
case 8{
comboBox.items = {"无影响","加重病情","促进死亡","直接死亡"};
}
}
}
//按钮
winform.vlist1.onClick = function(row/*行*/,col/*列*/,x,y){
select (col){
case 3,4,9
{..win.msgbox("您点击的是添加,位于"++row++"行"++col++"列吗?")}
}
}
//绘制按钮
winform.vlist1.onDrawCellRectBg = function(row,col,hdc,rc,bkcolor,text){
rc.left = rc.left + rc.width()/3;
rc.right = rc.right - rc.width()/2;
select(col) {
case 3,4,9 {
..gdi.fillRect(topointer(hdc),0xF8AC1A,rc); return true;
}
}
}
winform.show();
win.loopMessage();