MSHFlexGrid1使用技巧(一)[如何让MSHFlexGrid只能被选中一行]

类别:.NET开发 点击:0 评论:0 推荐:

MSHFlexGrid控件点击时可以选中多行,但有时我们需要仅仅选中一行,有一个小技巧:

 

Option Explicit
Dim CURRENTROW As Integer
Private Sub Form_Load()
Dim i As Integer, j As Integer
With MSHFlexGrid1
.Rows = 10
.Cols = 4
For i = 1 To 9
.TextMatrix(i, 0) = "第 " & i & " 行"
For j = 1 To 3
.TextMatrix(0, j) = "第 " & j & " 列"
.TextMatrix(i, j) = i & "," & j
Next
Next
End With
End Sub
Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    With MSHFlexGrid1
     .Row = .MouseRow
          CURRENTROW = .Row
      .Col = 0
        .ColSel = .Cols - 1
    End With
End Sub
Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
With MSHFlexGrid1
.RowSel = CURRENTROW
.ColSel = .Cols - 1
End With
End Sub

本文地址:http://com.8s8s.com/it/it44281.htm