不能选多行,包括fixcol

解决方案 »

  1.   

    Private Sub hflexgrid_EnterCell()
      '单击某一行时,改变该行颜色
      Dim i_Col As Integer
      Dim c_col As Integer
      c_col = Hflexgrid.Col
      If c_col > 0 Then
         For i_Col = 0 To Hflexgrid.Cols - 1
             Hflexgrid.Col = i_Col
             Hflexgrid.CellBackColor = &HFFFFC0     '变成蓝色
         Next i_Col
         Hflexgrid.Col = c_col
      End If
    End SubPrivate Sub hflexgrid_LeaveCell()
      '当某一行失去焦点时,改变该行颜色
      Dim i_Col As Integer
      Dim c_col As Integer
      c_col = Hflexgrid.Col
      For i_Col = 0 To Hflexgrid.Cols - 1
          Hflexgrid.Col = i_Col
          Hflexgrid.CellBackColor = vbWhite    '变成白色
      Next i_Col
      Hflexgrid.Col = c_col
    End Sub
      

  2.   

    用RowSel得到选中的行,然后改变整行的颜色
    tmprow=grid.rowsel
    grid.row=tmprow
    For i = 1 To grid.Cols - 1
            grid.Col = i: gridE.CellBackColor = vbBlue
    Next i
      

  3.   

    用API锁定控件然后再解锁就可实现了
    MouseDown中上锁
    MouseUp中解锁