Code: Select all
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim RIG As Integer, RIG1 As Integer, CLM As Integer, INDC As String
With Me.MSFlexGrid1
CLM = .ColSel
LASTCOL = .Cols - 2
If Me.CGIORNO.Text > "" And (CLM = 0 Or CLM = 51 Or CLM = 52 Or CLM = 53) Then
SortByColumn CLM
End If
If CLM = 0 Or (CLM >= 51 And CLM <= LASTCOL + 1) Then
Me.Text1.SetFocus
DoEvents
Exit Sub
End If
If .CellPicture = 0 And Me.LRIGA.Caption > "" And CLM > 0 And CLM < LASTCOL - 1 Then
RIG1 = .RowSel
RIG = .TextMatrix(RIG1, 0)
CLM = .Col
Set .CellPicture = Me.ImageList1.ListImages(1).Picture
.CellPictureAlignment = flexAlignCenterCenter
DoEvents
INDC = RIG & "-" & CLM & "-" & GIORNO '
COLLETTERS.Add Key:=INDC, Item:=INDC
.TextMatrix(RIG1, LASTCOL - 1) = .TextMatrix(RIG1, LASTCOL - 1) + 1
.TextMatrix(RIG1, LASTCOL + 1) = .TextMatrix(RIG1, LASTCOL + 1) - 1
DoEvents
Me.LNR.Caption = Format$(Me.LNR.Caption + 1, "#,##0")
Me.LNR1.Caption = Format$(Me.LNR1.Caption - 1, "#,##0")
DoEvents
INDICE = 0
Else
INDICE = 1
End If
If .CellPicture <> 0 And Me.LRIGA.Caption > "" And CLM > 0 And CLM < LASTCOL - 1 And INDICE = 1 Then
RIG1 = .RowSel
RIG = .TextMatrix(RIG1, 0)
CLM = .Col
Set .CellPicture = Nothing
DoEvents
.TextMatrix(RIG1, LASTCOL - 1) = .TextMatrix(RIG1, LASTCOL - 1) - 1
.TextMatrix(RIG1, LASTCOL + 1) = .TextMatrix(RIG1, LASTCOL + 1) + 1
DoEvents
Me.LNR.Caption = Format$(Me.LNR.Caption - 1, "#,##0")
Me.LNR1.Caption = Format$(Me.LNR1.Caption + 1, "#,##0")
DoEvents
INDC = RIG & "-" & CLM & "-" & GIORNO
COLLETTERS.Remove INDC
End If
End With
Me.Text1.SetFocus
End Sub
note:
msflexgrid1 and msflexgrid2 have exactly the same structure.