当前位置:首页 » 多媒体相关

100分关于msflexgrid或者mshflexgrid的问题,解决立即送分!!不够再加100!


我一直用的是datagrid控件,  
  请问我想在msflexgrid   ,mshflexgrid中实现  
  1.奇偶行不同的背景颜色,表头不同的颜色,当前单元格又是另外一种颜色.  
  2.msflexgrid如何绑定显示一个记录集?如何实现对其基本的增删改操作?如何让一次只显示30条记录呢?  
  不好意思,内容实在太多,请贴源码或者发相关例子到     hanksblue@sina.com!  
   
  贴一下相关的datagrid中的操作.以便让各位少写些代码,  
   
  提数据事件  
          set   conn   =   new   connection  
          conn.cursorlocation   =   aduseclient  
          conn.open   "联接字符串"                                                       ##########################################  
   
          set   rs   =   new   recordset  
           
          rs.open   "select   *   from   表",   conn,   adopenstatic,   adlockoptimistic  
          赋值给   datagrid   表  
          set   datagrid1.datasource   =   rs  
          表刷新  
          datagrid1.refresh  
   
          若绑定textbox(数组):  
          text1(0).datafield   =   字段1  
          text1(1).datafield   =   字段2  
          .........  
          dim   otext   as   textbox   textbox  
          for   each   otext   in   me.text1  
                  set   otext.datasource   =   rs  
          next  
   
   
   
   
  添加事件和保存  
          rs.addnew  
          保存  
          rs![字段a]   =   text1.text  
          rs![字段b]   =   text2.text  
          rs.updatebatch   adaffectall  
   
  删除  
          rs.delete  
          重新赋值给表  
          rs.requery  
          set   datagrid1.datasource   =   rs  
          datagrid1.refresh  
   
          其他相关操作:  
          上一条  
          if   not   rs.bof   then   rs.moveprevious  
          if   rs.bof   and   rs.recordcount   >   0   then  
                    已到最后返回  
                    rs.movefirst  
          end   if  
          下一条  
          if   not   rs.eof   then   rs.movenext         下一条  
          if   rs.eof   and   rs.recordcount   >   0   then  
                      已到最后返回  
                      rs.movelast  
          end   if  
          第一条  
          if   not   rs.bof   then   rs.movefirst  
          最末  
          if   not   rs.eof   then   rs.movelast  
  _____________________________________________  
  这里没有问题1和问题2中关于限定显示记录数的代码?  
  再次表示感谢!解决立即送分!!!!

推荐阅读

  • 文化部数字娱乐座谈会 庹祖海点“盛大盒子” [详细内容]
  • 显卡之争激烈 宏基开始选用N系移动GPU模块 [详细内容]
  • 简单制作OGG音乐及铃声(=) [详细内容]
  • 百度提升地图搜索服务 增17城市让出行更简单 [详细内容]
  • DRAM实行强制配货 模块厂商即将长期缺货 [详细内容]
  • 用PC套件为NOKIAS60系列机传送图铃及安装程序-By:Mendy [详细内容]
  • 个人网站不靠广告 能靠啥? [详细内容]
  • 网友回答:
    网友:gpo2002

    1,  
      version   5.00  
      object   =   "{0ecd9b60-23aa-11d0-b351-00a0c9055d8e}#6.0#0";   "mshflxgd.ocx"  
      begin   vb.form   form1    
            caption                   =       "form1"  
            clientheight         =       3195  
            clientleft             =       60  
            client               =       345  
            clientwidth           =       4680  
            linkic               =       "form1"  
            scaleheight           =       3195  
            scalewidth             =       4680  
            startupposition   =       3     窗口缺省  
            begin   mshierarchicalflexgridlib.mshflexgrid   mshflexgrid1    
                  height                     =       2775  
                  left                         =       240  
                  tabindex                 =       0  
                                            =       240  
                  width                       =       3975  
                  _extentx                 =       7011  
                  _extenty                 =       4895  
                  _version                 =       393216  
                  rows                         =       20  
                  cols                         =       20  
                  fixedcols               =       0  
                  highlight               =       0  
                  fillstyle               =       1  
                  allowuserresizing=       3  
                  _numberofbands     =       1  
                  _band(0).cols       =       20  
            end  
      end  
      attribute   vb_name   =   "form1"  
      attribute   vb_globalnamespace   =   false  
      attribute   vb_creatable   =   false  
      attribute   vb_predeclaredid   =   true  
      attribute   vb_exposed   =   false  
      option   explicit  
       
      private   oldrow                     as   long  
      private   oldcol                     as   long  
      private   oldcolor                 as   ole_color  
       
      private   sub   colflex()  
       
              dim   i                       as   integer  
       
              with   mshflexgrid1  
                       
                      .fillstyle   =   flexfillrepeat  
                      for   i   =   .fixedrows   +   1   to   .rows   -   1   step   2  
                              .row   =   i  
                              .col   =   .fixedcols  
                              .colsel   =   .cols   -   1  
                              .cellbackcolor   =   vbinfobackground  
                      next   i  
               
              end   with  
               
      end   sub  
       
      private   sub   form_load()  
       
              oldrow   =   0  
              oldcol   =   0  
              oldcolor   =   mshflexgrid1.backcolorfixed  
               
              call   colflex  
               
      end   sub  
       
      private   sub   form_resize()  
              mshflexgrid1.move   me.scaleleft,   me.scale,   me.scalewidth,   me.scaleheight  
      end   sub  
       
      private   sub   mshflexgrid1_rowcolchange()  
               
              dim   nowrow                             as   long  
              dim   nowcol                             as   long  
              dim   nowcolor                         as   ole_color  
               
              nowcol   =   mshflexgrid1.col  
              nowrow   =   mshflexgrid1.row  
              nowcolor   =   mshflexgrid1.cellbackcolor  
               
              mshflexgrid1.col   =   oldcol  
              mshflexgrid1.row   =   oldrow  
              mshflexgrid1.cellbackcolor   =   oldcolor  
               
              mshflexgrid1.col   =   nowcol  
              mshflexgrid1.row   =   nowrow  
              mshflexgrid1.cellbackcolor   =   vbred  
               
              oldcol   =   nowcol  
              oldrow   =   nowrow  
              oldcolor   =   nowcolor  
               
      end   sub  
       
      2,太晚了,明天再说

    网友:gpo2002

    双击cell重新定位rst对象,有了当前rst,删除,修改就不难了吧  
     

    网友:hzybc

    一次只显示30条记录  
      可以用for   循环控制  
      for   i=1   to   30  
            msflexgrid1.textmatrix(i,0)=rs!字段1  
            msflexgrid1.textmatrix(i,1)=rs!字段2  
      next   i  
     

    网友:mark3798

    同意楼上那位,不过我要说两句,得及时增加行  
      一般是有两个for   语句结合起来写的。把下面这句放在第一个for的结尾就可以了。  
      mshflexgrid1.rows=mshflexgrid1.rows+1

    .

    讨论区

    Login