7,765
社区成员
发帖
与我相关
我的任务
分享
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim i As Long, j As Long
If MSFlexGrid1.MouseRow = 0 Then Exit Sub
If Button = 1 Then
If Shift = 2 Then
With MSFlexGrid1
For j = 1 To .Cols - 1
.Col = j
If .CellBackColor = &H8000000D Then
.CellForeColor = &H80000008
.CellBackColor = &H80000005
.RowData(.Row) = 0
Else
.CellForeColor = &H8000000E
.CellBackColor = &H8000000D
.RowData(.Row) = 1
End If
Next
End With
ElseIf Shift = 1 Then
With MSFlexGrid1
If .Row <= .RowSel Then
For i = .Row To .RowSel
.RowData(i) = 1
Next
Else
For i = .Row To .RowSel Step -1
.RowData(i) = 1
Next
End If
End With
End If
End If
End Sub
Private Sub MSFlexGrid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim i As Long, j As Long
Dim lngRow As Long, lngRowSel As Long
If MSFlexGrid1.MouseRow = 0 Then Exit Sub
DoEvents
If Shift = 0 Then
With MSFlexGrid1
.Redraw = False
lngRow = .Row
lngRowSel = .RowSel
For i = 1 To .Rows - 1
If i <> lngRowSel And .RowData(i) = 1 Then
.Row = i
For j = 1 To .Cols - 1
.Col = j
.CellForeColor = &H80000008
.CellBackColor = &H80000005
Next
.RowData(i) = 0
End If
Next
.Row = lngRow
If .Row <= lngRowSel Then
For i = lngRow To lngRowSel
.Row = i
.RowData(i) = 1
For j = 1 To .Cols - 1
.Col = j
.CellForeColor = &H8000000E
.CellBackColor = &H8000000D
Next
Next
Else
For i = lngRow To lngRowSel Step -1
.Row = i
.RowData(i) = 1
For j = 1 To .Cols - 1
.Col = j
.CellForeColor = &H8000000E
.CellBackColor = &H8000000D
Next
Next
End If
.Redraw = True
End With
End If
End Sub