Private Sub MSFlexGrid1_Click()
With Me.MSFlexGrid1
RIGA = .Row
'here i need to count, from column 1 to column 50, how many image are in row RIGA, and insert number of image in column NR
'in my case row 6
end Wtih
End sub
note:
RIGA as Integer, is a public dim
count IMAGE in row click events msflexgrid
-
- PlatinumLounger
- Posts: 4353
- Joined: 26 Apr 2010, 17:36
count IMAGE in row click events msflexgrid
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78446
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: count IMAGE in row click events msflexgrid
I cannot test this myself.
Code: Select all
Dim CONTA As Long
Dim C As Long
CONTA = 0
With Me.MSFlexGrid1
RIGA = .Row
For C = 1 To 50
.Col = C
If Not .CellPicture Is Nothing Then
CONTA = CONTA +1
End If
Next C
.TextMatrix(RIGA, 51) = CONTA
End With
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 548
- Joined: 27 Jun 2021, 10:46
Re: count IMAGE in row click events msflexgrid
>here i need to count, from column 1 to column 50
Do you? Surely you are adding (and possibly removing) the images in your code at runtime, since you cannot do so at designtime.? Simply maintain the total in that code, rather than counting after the fact. Fort example. using code you have previously posted:
Private Sub MSFlexGrid1_Click()
Dim LASTCOL As Integer
LASTCOL = 51
With Me.MSFlexGrid1
COLONNA = .Col
RIGA = .Row
If .CellPicture = 0 And RIGA > 0 And COLONNA > 0 And COLONNA < LASTCOL Then
'.TextMatrix(RIGA, COLONNA) = "0"
'.CellAlignment = flexAlignLeftCenter
'Set .CellPicture = LoadPicture(App.Path & "\IMG\" & "T.jpg")
Set .CellPicture = Me.ImageList1.ListImages(1).Picture
.TextMatrix(RIGA, 51)=.TextMatrix(RIGA, 51)+1
.CellPictureAlignment = flexAlignCenterCenter
'Set .CellPicture = LoadPicture(App.Path & "\IMG\" & "OMBRELLONE_ROSSO.jpg")
'.CellAlignment = flexAlignCenterCenter
Me.LCOLONNA.Caption = COLONNA
Me.LRIGA.Caption = RIGA
' .Tag = ""
' .Tag = COLONNA & "-" & RIGA
i think the arry code go here?
Else
'.TextMatrix(RIGA, COLONNA) = ""
'Set .CellPicture = Nothing
'.TextMatrix(RIGA, COLONNA) = ""
Set .CellPicture = LoadPicture("")
.TextMatrix(RIGA, 51)=.TextMatrix(RIGA, 51)-1
'think
'here the code to delete element in array
' .Tag = ""
'Stop
End If
End With
Me.Text1.SetFocus
End Sub
Do you? Surely you are adding (and possibly removing) the images in your code at runtime, since you cannot do so at designtime.? Simply maintain the total in that code, rather than counting after the fact. Fort example. using code you have previously posted:
Private Sub MSFlexGrid1_Click()
Dim LASTCOL As Integer
LASTCOL = 51
With Me.MSFlexGrid1
COLONNA = .Col
RIGA = .Row
If .CellPicture = 0 And RIGA > 0 And COLONNA > 0 And COLONNA < LASTCOL Then
'.TextMatrix(RIGA, COLONNA) = "0"
'.CellAlignment = flexAlignLeftCenter
'Set .CellPicture = LoadPicture(App.Path & "\IMG\" & "T.jpg")
Set .CellPicture = Me.ImageList1.ListImages(1).Picture
.TextMatrix(RIGA, 51)=.TextMatrix(RIGA, 51)+1
.CellPictureAlignment = flexAlignCenterCenter
'Set .CellPicture = LoadPicture(App.Path & "\IMG\" & "OMBRELLONE_ROSSO.jpg")
'.CellAlignment = flexAlignCenterCenter
Me.LCOLONNA.Caption = COLONNA
Me.LRIGA.Caption = RIGA
' .Tag = ""
' .Tag = COLONNA & "-" & RIGA
i think the arry code go here?
Else
'.TextMatrix(RIGA, COLONNA) = ""
'Set .CellPicture = Nothing
'.TextMatrix(RIGA, COLONNA) = ""
Set .CellPicture = LoadPicture("")
.TextMatrix(RIGA, 51)=.TextMatrix(RIGA, 51)-1
'think
'here the code to delete element in array
' .Tag = ""
'Stop
End If
End With
Me.Text1.SetFocus
End Sub