本帖最后由 baeta 于 2009-06-14 10:28:19 编辑

解决方案 »

  1.   

    Private Sub Form_Load()
    MSHFlexGrid1.Row = 3
    MSHFlexGrid1.Col = 1
    MSHFlexGrid1.ColSel = MSHFlexGrid1.Cols - 1
    MSHFlexGrid1.RowSel = MSHFlexGrid1.Rows - 1
     MSHFlexGrid1.CellBackColor = vbRed
     MSHFlexGrid1.BackColorSel = vbRed
    End Sub
      

  2.   

    把改底色的语句写成一个过程,就可以方便调用了,如:Sub ChangeGridColor(LeftC as long, RightC as long, TopR as long, ButtomR as long, Color as long)
    dim I as long
    dim L as long
    with grid1
       .visible=false
       for I= leftc to rightc
          .Col=I
          for L=topr to ButtomR                 
             .Row = L 
             .CellForeColor = Color
          next
       next
       .visible=true
    end with
    end sub这样就简单多了:  ChangeGridColor 1,3,8,12,vbred
      

  3.   

    循环写成一个sub,然后每次调用就可以了Sub ChangeGridColor(LeftC as long, RightC as long, TopR as long, ButtomR as long, Color as long)
    dim I as long
    dim L as long
    with grid1
      .visible=false
      for I= leftc to rightc
          .Col=I
          for L=topr to ButtomR               
            .Row = L
            .CellForeColor = Color
          next
      next
      .visible=true
    end with
    end sub 
      

  4.   

    遍历MSHFlexGrid 那速度会把人折磨死的
      

  5.   

    cellforecolor不是给字加颜色吗?怎么变成格子颜色了?
    应该是cellbackcolor吧