Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Flexgrid with row(s) or column(s) selected
Author:
amit kumar dhiman
E-mail:
Click to e-mail author
Submitted:
9/7/2006
Version:
VB6
Compatibility:
VB6
Category:
Controls
Views:
32802
This code is able to select row(s) or column(s) by using ctrl key. This code can be modified according to need easily . The name of MSFLEXGRID is "fgtable".
Declarations:
'These variable having global scop dim COLFLAG as boolean dim ROWFLAG as boolean
Code:
Private Sub fgTable_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) With fgTable If .Rows = 0 And .Cols = 0 Then Exit Sub End If Dim lRowOriginal As Long: lRowOriginal = .MouseRow Dim lCOLOriginal As Long: lCOLOriginal = .MouseCol If lRowOriginal = 0 And lCOLOriginal = 0 Or lRowOriginal > 1 And lCOLOriginal > 1 Then UnSelectAllGridRows .row = lRowOriginal .col = lCOLOriginal Else If lCOLOriginal = 0 And lRowOriginal > 1 Then '--------------------------------------- 'This means row(s) is selected.so deselect all the colun(s)first '---------------------------------------- If ROWFLAG = True And COLFLAG = False Then UnSelectAllGridRows End If COLFLAG = True ROWFLAG = False If (Shift And vbShiftMask) = vbShiftMask Then SelectionOneAfterTheOther Else If (Shift And vbCtrlMask) = vbCtrlMask Then SelectUnSelectGridRow Else UnSelectAllGridRows .RowSel = .row .ColSel = .Cols - 1 .CellBackColor = vbHighlight .CellForeColor = vbHighlightText End If End If Else If ROWFLAG = False And COLFLAG = True Then ''''This means colum(s) is selected.so clear all the row(s)first UnSelectAllGridCOLS End If COLFLAG = False ROWFLAG = True If (lRowOriginal = 0 Or lRowOriginal = 1) And lCOLOriginal > 0 Then If (Shift And vbShiftMask) = vbShiftMask Then SelectionOneAfterTheOtherCOL Else If (Shift And vbCtrlMask) = vbCtrlMask Then SelectUnSelectGridRowCOL Else UnSelectAllGridCOLS .ColSel = .col .RowSel = .Rows - 1 .CellBackColor = vbHighlight .CellForeColor = vbHighlightText End If End If End If End If End If End With End Sub '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''till here ------------------------------------------------------------------------------ Private Sub UnSelectAllGridRows() Dim lRowOriginal As Long With fgTable lRowOriginal = .row .row = .FixedRows .col = .FixedCols .RowSel = .Rows - 1 .ColSel = .Cols - 1 .FillStyle = flexFillRepeat .HighLight = flexHighlightNever .CellBackColor = .BackColor .CellForeColor = .ForeColor .row = lRowOriginal .ColSel = .Cols - 1 End With End Sub _______________________________________________ Private Sub UnSelectAllGridCOLS() Dim lCOLOriginal As Long With fgTable lCOLOriginal = .col .row = .FixedRows .col = .FixedCols .RowSel = .Rows - 1 .ColSel = .Cols - 1 .FillStyle = flexFillRepeat .HighLight = flexHighlightNever .CellBackColor = .BackColor .CellForeColor = .ForeColor .RowSel = .Rows - 1 .col = lCOLOriginal End With End Sub _______________________________________________ 'SelectionOneAfterTheOther Private Sub SelectionOneAfterTheOther() Dim lRow As Long Dim lMouseRow As Long With fgTable lRow = .row lMouseRow = .MouseRow .FillStyle = flexFillRepeat .row = lRow .col = .FixedCols .RowSel = lMouseRow .ColSel = .Cols - 1 .HighLight = flexHighlightNever .CellBackColor = vbHighlight .CellForeColor = vbHighlightText End With End Sub ______________________________________________ Private Sub SelectionOneAfterTheOtherCOL() Dim lRow As Long Dim lMouseRow As Long Dim LMOUSECOL As Long Dim LCOL As Long With fgTable lRow = .row LCOL = .col ' lMouseRow = .MouseRow LMOUSECOL = .MouseCol .FillStyle = flexFillRepeat .row = .FixedRows ' lRow .col = LCOL .RowSel = .Rows - 1 ' lMouseRow .ColSel = LMOUSECOL .HighLight = flexHighlightNever .CellBackColor = vbHighlight .CellForeColor = vbHighlightText End With End Sub _______________________________________________ Private Sub SelectUnSelectGridRow() With fgTable .row = .MouseRow .FillStyle = flexFillRepeat .col = .FixedCols .ColSel = .Cols - 1 .HighLight = flexHighlightNever If .CellBackColor = vbHighlight Then .CellBackColor = .BackColor .CellForeColor = .ForeColor tableDataSelected = False Else .CellBackColor = vbHighlight .CellForeColor = vbHighlightText tableDataSelected = True End If End With End Sub ______________________________________________ Private Sub SelectUnSelectGridRowCOL() With fgTable .row = .FixedRows ' .MouseRow .FillStyle = flexFillRepeat .col = .MouseCol '.FixedCols .RowSel = .Rows - 1 .HighLight = flexHighlightNever If .CellBackColor = vbHighlight Then .CellBackColor = .BackColor .CellForeColor = .ForeColor tableDataSelected = False Else .CellBackColor = vbHighlight .CellForeColor = vbHighlightText tableDataSelected = True End If End With End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement