在flexgrid中,当我选中一行时,想将此行的颜色改变,如何进行,问题解决就给分,参与的也有分.

解决方案 »

  1.   

    老大,请这看这段代码(转载的)吧,可能对你有点帮助的!
    '*********************************************************************
    '*              改变grid颜色,把单数行和双数行的颜色设置成不同的颜色!
    '*********************************************************************
    Public Sub SetGridColor(TheGrid As Control, row_col As Boolean, RowsColor As Long, ColsColor As Long)
        Dim i As Integer
        Dim J As Integer
        Dim k As Long
     
        TheGrid.Redraw = False
     
        TheGrid.BackColorBkg = &H808080
        TheGrid.BackColorFixed = &HC0C0C0
     
    If row_col Then
        For J = TheGrid.FixedRows To TheGrid.Rows - 1
            If k = ColsColor Then
                k = RowsColor
            Else
                k = ColsColor
            End If
     
            For i = TheGrid.FixedCols To TheGrid.Cols - 1
                TheGrid.Row = J: TheGrid.Col = i
                TheGrid.CellBackColor = k
                TheGrid.CellForeColor = &H80000008
            Next
        Next    TheGrid.Row = 0
            For i = 0 To TheGrid.Cols - 1
                TheGrid.Col = i
                TheGrid.CellAlignment = 4
            Next
            TheGrid.Redraw = True
    Else
        For J = TheGrid.FixedCols To TheGrid.Cols - 1
            If k = ColsColor Then
                k = RowsColor
            Else
                k = ColsColor
            End If
     
            For i = TheGrid.FixedRows To TheGrid.Rows - 1
                TheGrid.Col = J: TheGrid.Row = i
                TheGrid.CellBackColor = k
                TheGrid.CellForeColor = &H80000008
            Next
        Next        TheGrid.Col = 0
        For i = 0 To TheGrid.Rows - 1
            TheGrid.Row = i
            TheGrid.CellAlignment = 4
        Next
            TheGrid.Redraw = TrueEnd IfEnd Sub
      

  2.   

    在flexgrid的属性中的BackColorSel属性指定相应颜色就可以了
      

  3.   

    MSFlexGrid1.FocusRect = flexFocusNone
    MSFlexGrid1.SelectionMode = flexSelectionByRow
      

  4.   

    ZQY801105(烟火)呵呵,这不是转帖我的吗?
      

  5.   

    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
      

  6.   

    To---->Abecedarian() ,是呀,老大,不要见怪吧,都 是为了帮助兄弟们呀!