Use a public routine for msflexgrid

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

Use a public routine for msflexgrid

Post by sal21 »

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
this is the MouseDown code for msflexgrid1, how to use also for msflexgrid2?

note:
msflexgrid1 and msflexgrid2 have exactly the same structure.

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Use a public routine for msflexgrid

Post by HansV »

Will they also use the same controls CGIORNO, Text1, LRIGA, ImageList1, LNR, and LNR1?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

Re: Use a public routine for msflexgrid

Post by sal21 »

HansV wrote:
29 Sep 2021, 14:59
Will they also use the same controls CGIORNO, Text1, LRIGA, ImageList1, LNR, and LNR1?
Good eyes!

no, for MSFlexGrid2 are:

CGIORNO1, LRIGA1, LNRR, and LNR11

Text1, ImageList1 are the same

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Use a public routine for msflexgrid

Post by HansV »

That makes it more difficult.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

Re: Use a public routine for msflexgrid

Post by sal21 »

HansV wrote:
29 Sep 2021, 16:33
That makes it more difficult.
NO prob, resolved with copy of the same structure for the grid1 and change, the refered value.

tks in other case.