虚表 —— 自定义数据适配器 + 频繁更新数据 + 定时刷新例程

光庆 2024-6-20 1270

方法一,根据更新的次数,每更新30次数据,刷新一次,以降低刷新频率,减少系统消耗

Code AardioLine:29复制
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
    • import win.ui;
    • import godking.vlistEx
    • /*DSG{{*/
    • var winform = win.form(text="aardio form";right=749;bottom=699)
    • winform.add(
    • vlistEx={cls="vlistEx";text="自定义控件";left=10;top=10;right=750;bottom=610;z=1}
    • )
    • /*}}*/
    • winform.show();
    • winform.vlistEx.setColumns({"编号","语文","数学"},{250,250,-1}/*列宽*/,/*格式*/)
    • var list = {}
    • winform.vlistEx.setCustomAdapter(10000,function(row,col){
    • return list[[row]][[col]];
    • })
    • var index=1;
    • winform.vlistEx.autoRedraw = false;
    • winform.setInterval(
    • function(){
    • list[index] = { index,..math.random(50,100),..math.random(50,100)};
    • if index<10000 index = index +1;
    • else index = 1;
    • if !(index%30) {
    • winform.vlistEx.redraw(true);
    • winform.vlistEx.ensureVisible(index);
    • }
    • },0
    • )
    • win.loopMessage();

    方法二,更新数据与刷新表格,分别用2个时钟控制,互不干扰。

    Code AardioLine:31复制
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
    • import win.ui;
    • import godking.vlistEx
    • /*DSG{{*/
    • var winform = win.form(text="aardio form";right=749;bottom=699)
    • winform.add(
    • vlistEx={cls="vlistEx";text="自定义控件";left=10;top=10;right=750;bottom=610;z=1}
    • )
    • /*}}*/
    • winform.show();
    • winform.vlistEx.setColumns({"编号","语文","数学"},{250,250,-1}/*列宽*/,/*格式*/)
    • var list = {}
    • winform.vlistEx.setCustomAdapter(10000,function(row,col){
    • return list[[row]][[col]];
    • })
    • var index=1;
    • winform.vlistEx.autoRedraw = false;
    • winform.setInterval(
    • function(){
    • list[index] = { index,..math.random(50,100),..math.random(50,100)};
    • if index<10000 index = index +1;
    • else index = 1;
    • },0
    • )
    • winform.setInterval(
    • function(){
    • winform.vlistEx.redraw(true);
    • winform.vlistEx.ensureVisible(index);
    • },500
    • )
    • win.loopMessage();

    效果:

    最新回复 (0)
    返回