您的位置:程序门 -> vb -> 数据库(包含打印,安装,报表)



mshflexgrid显示速度非常慢


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


mshflexgrid显示速度非常慢
发表于:2007-06-27 22:52:43 楼主
private   sub   showcls()   '显示mshflexgrid
dim   hh   as   integer
dim   i   as   integer
hh   =   1
with   grid1
        .clear
        .backcolor   =   &hffffff
        .formatstring   =   "^   ¦^存货代码 ¦^类别编码 ¦^存货名称及规格 ¦^结存数量 ¦^结存金额 "
        .colwidth(0)   =   500
        .colwidth(1)   =   1200
        .colwidth(2)   =   1500
        .colwidth(3)   =   4000
        .colwidth(4)   =   1800
        .colwidth(5)   =   2000
        for   i   =   0   to   5
                .colalignmentfixed(i)   =   4
        next   i
        for   i   =   1   to   3  
                .colalignment   =   1
        next   i
        for   i   =   4   to   5
                .colalignment   =   7
        next   i
        if   rs.state   <>   adstateclosed   then
                rs.close
        end   if
        rs.cursorlocation   =   aduseclient
        '首先读取存货项目表
        rs.open   "select   *   from   icitem   order   by   fitemid ",   cn,   adopenkeyset,   adlockpessimistic
        if   rs.recordcount   <>   0   then
                rs.movefirst
                .rows   =   rs.recordcount   +   1
                do   until   rs.eof
                        .row   =   hh
                        .col   =   0
                        .text   =   hh
                        .col   =   1
                        .text   =   rs!fitemid
                      .cellbackcolor   =   &hc0ffff     '定义第2、3、4列的背景色为黄色,为以后是否能编辑定义,黄色不能修改
                        .col   =   2
                        .text   =   rs!lbcode
                        .cellbackcolor   =   &hc0ffff
                        .col   =   3
                        .text   =   rs!fitemname   &   "     "   &   rs!fmodel
                        .cellbackcolor   =   &hc0ffff
                        .col   =   4
                        .text   =   format(rs!fbegqty,   "#,##0.00 ")
                        .col   =   5
                        .text   =   format(rs!fbegbal,   "#,##0.00 ")
                        hh   =   hh   +   1
                        rs.movenext
                loop
                  if   hh   =   .rows   then
                        .rows   =   hh   +   1
                  end   if
                        .textmatrix(hh,   0)   =   hh
                        .textmatrix(hh,   1)   =   "合       计 "
                if   rssum.state   <>   adstateclosed   then
                        rssum.close
                end   if
                rssum.open   "select   sum(fbegbal)   from   icinitdata   where   left(fclsid, "   &   ijbcd   &   ")= ' "   &   left(schlb,   ijbcd)   &   " '   and   fstockid= "   &   ick   &   " ",   cn,   adopenkeyset,   adlockpessimistic
                .col   =   5
                .text   =   format(rssum.fields(0),   "#,##0.00 ")
                for   i   =   1   to   5
                        .row   =   hh
                      .col   =   i
                      .cellbackcolor   =   &hc0ffff   '最后一行全为黄色,即单元格不能编辑
                next   i
        else
                .backcolor   =   &hc0ffff
                .rows   =   rs.recordcount   +   2
        end   if
        rs.close
        .redraw   =   false
        .backcolorfixed   =   rgb(190,   218,   178)     '定义固定表头的背景色
        .redraw   =   true
end   with
end   sub
这段代码执行下来的时候,记录少的话还可以,但是如果比较多的话,显示出来就非常慢(100条以内都慢),有没有能使显示速度快一点的办法!
发表于:2007-06-28 10:13:171楼 得分:0
你的.redraw   =   false这句放错位置了。
这句话的意思是防止控件重绘的。你应该将这句放在添加数据之前,否则你每添加一条数据,控件都会重新绘制一次,速度可想而知了。


═══════════════════
http://www.egooglet.com   资料、源码下载

http://bbs.j2soft.cn   论坛交流
═══════════════════
发表于:2007-06-28 12:37:512楼 得分:0
个人感觉是用的循环太多的缘故,不过提不出什么好的建议
发表于:2007-06-30 12:53:583楼 得分:0
我一般是在充填数据前将其visible属性设置为false,完了再设回true。
发表于:2007-06-30 19:41:484楼 得分:0
不使用循环增加数据,建议使用记录集绑定。

======================================================
红松软件     http://hongsong.huanqiuit.com/
软件论坛     http://5x51.com/hongsong/
本网站推出只要注册本站会员,就送一套正版软件活动,此
活动截至日期2007-08-15。所需要点软件在本网站中自己挑
选一个。

论坛前10位会员,赠送vip会员资格!!!
======================================================


快速检索

最新资讯