get tag value from msflexgrid
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
get tag value from msflexgrid
Possible to get .tag value, if is present in a cell, with MSFlexGrid1_MouseMove event?
-
- Administrator
- Posts: 78535
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: get tag value from msflexgrid
As far as I know, the Tag property applies to the MSFlexGrid control as a whole, not to individual cells.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: get tag value from msflexgrid
haaaa...
but i need to store on individual cell of msflexgrid a value, but hided in cell... other way?
but i need to store on individual cell of msflexgrid a value, but hided in cell... other way?
-
- Administrator
- Posts: 78535
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: get tag value from msflexgrid
You could create an array (for example: GridArray) with the same number of rows and columns as the MSFlexGrid control, and store the values in the array.
The value for the cell you move the mouse over is GridArray(MSFlexGrid1.MouseRow, MSFlexGrid1.MouseCol)
The value for the cell you move the mouse over is GridArray(MSFlexGrid1.MouseRow, MSFlexGrid1.MouseCol)
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: get tag value from msflexgrid
hummmm...
tks for susggestion, but very complex for me.
my grid have 50 row and 50 column.
actually the code i have is :
Code: Select all
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
.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
[b]i think the arry code go here?[/b]
Else
'.TextMatrix(RIGA, COLONNA) = ""
'Set .CellPicture = Nothing
'.TextMatrix(RIGA, COLONNA) = ""
Set .CellPicture = LoadPicture("")
'think
[b] 'here the code to delete element in array[/b]
' .Tag = ""
'Stop
End If
End With
Me.Text1.SetFocus
End Sub
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78535
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: get tag value from msflexgrid
I don't know what you want to do with the array...
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 562
- Joined: 27 Jun 2021, 10:46
Re: get tag value from msflexgrid
>Private Sub MSFlexGrid1_Click()
But you asked about MouseMove. What is your MouseMove code?
And how were you (originally) intending to set the tags that you want to retrieve?
But you asked about MouseMove. What is your MouseMove code?
And how were you (originally) intending to set the tags that you want to retrieve?
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78535
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 4StarLounger
- Posts: 562
- Joined: 27 Jun 2021, 10:46
Re: get tag value from msflexgrid
Here's a minimalist example, which assumes you want the 'tags' to be text. It also assumes you have a form with an MSFlexGrid control called MSFlexGrid2, and a command button called Command2. You'll need to populate the Grid by clicking the button before you try clicking on any random cell. It demonstrates a method, but is NOT production level code.
Code: Select all
Option Explicit
Private ShadowGrid() As String
Private Sub Command2_Click()
PopulateGrid MSFlexGrid2
End Sub
Public Sub PopulateGrid(myGrid As MSFlexGrid)
Dim myRow As Long
Dim myCol As Long
With myGrid
ReDim ShadowGrid(1 To .Cols - 1, 1 To .Rows - 1)
For myRow = 1 To .Rows - 1
For myCol = 1 To .Cols - 1
.Row = myRow
.Col = myCol
.Text = "Hello" & myCol * myRow
ShadowGrid(myCol, myRow) = "Tag: Cell " & myCol & ", " & myRow
Next
Next
End With
End Sub
Private Sub MSFlexGrid2_Click()
With MSFlexGrid2
If .MouseRow > 0 And .MouseCol > 0 Then
Debug.Print ShadowGrid(.MouseCol, .MouseRow)
' or, since .Col and .Row are (mostly) the same as .MouseCol and .MouseRow in the msflexgrid's click event
Debug.Print ShadowGrid(.Col, .Row)
End If
End With
End Sub