首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

MSHFlexGrid中单击某一行变色,怎么实现

2012-01-18 
MSHFlexGrid中单击某一行变色,如何实现MSHFlexGrid中单击某一行变色,如何实现.如果有rar实例,请提供链接.

MSHFlexGrid中单击某一行变色,如何实现
MSHFlexGrid中单击某一行变色,如何实现.如果有rar实例,请提供链接.谢谢.

[解决办法]

VB code
Private Sub MSHFlexGrid1_Click()    ChangeRowBackColor MSHFlexGrid1.Row, vbYellowEnd Sub'---------------------------------------------------' 过程名    : ChangeRowBackColor' 时间      : 2010-4-29 19:31' 作者      : 杨过.网狐.cn(csdn bcrun)' 功能      :' 说明      :' 备注      : http://topic.csdn.net/u/20100429/19/d0feef9f-dde8-4e5b-9460-159df47f737d.html'MSHFlexGrid中单击某一行变色,如何实现 ning1958'---------------------------------------------------'Private Sub ChangeRowBackColor(ByVal lActiveRow As Long, ByVal lNewColor As Long)    Dim lRow As Long, lCol As Long    Dim lRowIndex As Long, lColIndex As Long    With MSHFlexGrid1        .Row = lActiveRow        For lColIndex = 0 To .Cols - 1            .Col = lColIndex            .CellBackColor = lNewColor                Next lColIndex    End WithEnd Sub
[解决办法]
VB code
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 Sub

Private 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

热点排行