急,在DataGrid中可不可以点击一行,使这行的变色。

解决方案 »

  1.   

    '这个是用于mshflexgrid的Private Sub mshflexgrid_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 =vbred
         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