正文

加强型的msflexgrid32005-07-22 13:10:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/leafage/3084.html

分享到:

'以下程式处理Multi-column Selection的问题 Private Sub ProcMultiColSel(ByVal Shift As Integer) Dim i As Long, HaveSel As Boolean Dim SelSt As Long, SelEnd As Long Dim OldRowSel As Long, OldColSel As Long With MSFlexGrid1 OldRowSel = .RowSel: OldColSel = .ColSel If HaveSelEntireCol Then    '如果有整行被选取的清况,则计算选取的起始结束行    SelSt = IIf(.Col <= .ColSel, .Col, .ColSel)    SelEnd = IIf(.Col > .ColSel, .Col, .ColSel)    For i = SelSt To SelEnd        ColSelect(i) = True    Next    .CellBackColor = .BackColorSel    If Shift <> vbCtrlMask Then '没有按Ctl键则清除其他Column的Selection       Call RefreshCols(SelSt, SelEnd)    End If Else    HaveSel = False    For i = 1 To .Cols - 1        HaveSel = HaveSel Or ColSelect(i)    Next    If HaveSel Then       Call RefreshAll    End If End If .RowSel = OldRowSel .ColSel = OldColSel End With End Sub 'Check是否有整行的选取 Private Function HaveSelEntireCol() As Boolean With MSFlexGrid1 If .RowSel = (.Rows - 1) And .Row = 1 Then    HaveSelEntireCol = True Else    HaveSelEntireCol = False End If End With End Function '清除所有的Selection Private Sub RefreshAll() Dim SaveCol As Long, SaveRow As Long, i As Long With MSFlexGrid1     SaveCol = .Col: SaveRow = .Row     .Col = 1: .Row = 1     .ColSel = .Cols - 1: .RowSel = .Rows - 1      MSFlexGrid1.CellBackColor = SaveCellBkColor     .Col = SaveCol: .Row = SaveRow     .ColSel = SaveCol: .RowSel = SaveRow     For i = 1 To .Cols - 1     ColSelect(i) = False     Next End With End Sub '清除其他Column的Selection除了columns From Selst to SelEnd外,其他清除 Private Sub RefreshCols(ByVal SelSt As Long, ByVal SelEnd As Long) Dim SaveCol As Long, SaveRow As Long, i As Long With MSFlexGrid1    SaveCol = .Col: SaveRow = .Row    For i = 1 To .Cols - 1       If Not (i >= SelSt And i <= SelEnd) And ColSelect(i) Then     .Col = i: .Row = 1     .ColSel = i: .RowSel = .Rows - 1     MSFlexGrid1.CellBackColor = SaveCellBkColor     ColSelect(i) = False       End If    Next    .Col = SaveCol: .Row = SaveRow    .ColSel = SaveCol: .RowSel = SaveRow End With End Sub Private Sub MSFlexGrid1_Scroll() SendKeys "{ESC}" End Sub   

阅读(3094) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册