I just have a msflexgrid filled.
now, when i click on a cell, for example on: ABBAZIA, i need to insert before ABBAZIA an icon (c:\icon\flip.ico)
if i click on a other cell, for example: BERGOGNA, i need to add before BERGOGNA an icon (c:\icon\flip.ico), and delete the last icon added to ABBAZIA ecc ...
i hope you understand me.
note:
only for the value in comun 8
add ico in msflexgrid
-
- PlatinumLounger
- Posts: 4481
- Joined: 26 Apr 2010, 17:36
add ico in msflexgrid
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 79365
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: add ico in msflexgrid
I cannot test this, so there may be a better way. Create a blank icon in the same folder named Blank.ico
Code: Select all
Private Sub MSFlexGrid1_Click()
Static OldRow As Long
Dim NewRow As Long
With Me.MSFlexGrid1
If .Col = 8 And .Row <> OldRow Then
NewRow = .Row
.Row = OldRow
.CellPicture = LoadPicture("c:\icon\blank.ico")
.Row = NewRow
.CellPicture = LoadPicture("c:\icon\flip.ico")
OldRow = NewRow
End If
End With
End Sub
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4481
- Joined: 26 Apr 2010, 17:36
Re: add ico in msflexgrid
.CellPicture = higlight for error!HansV wrote: ↑28 Oct 2023, 10:58I cannot test this, so there may be a better way. Create a blank icon in the same folder named Blank.ico
Code: Select all
Private Sub MSFlexGrid1_Click() Static OldRow As Long Dim NewRow As Long With Me.MSFlexGrid1 If .Col = 8 And .Row <> OldRow Then NewRow = .Row .Row = OldRow .CellPicture = LoadPicture("c:\icon\blank.ico") .Row = NewRow .CellPicture = LoadPicture("c:\icon\flip.ico") OldRow = NewRow End If End With End Sub
invalid use of property....
-
- Administrator
- Posts: 79365
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4481
- Joined: 26 Apr 2010, 17:36
-
- 5StarLounger
- Posts: 611
- Joined: 27 Jun 2021, 10:46
Re: add ico in msflexgrid
<edit: ah, looks like our posts crossed)
You need Set
I'd slightly modify Han's code to:
But bear in mind that in the msflexgrid control neither the icon or text in the cell know anything about each other, so you'll need to figure out a way to position the text appropriately when the icon is inserted. The simple alignment settings available for the pricture and/or the text alone may not be sufficient. Personally, I'd probably introduce an extra column just to display the icon.
You need Set
I'd slightly modify Han's code to:
Code: Select all
Private Sub MSFlexGrid1_Click()
Static OldRow As Long
Dim NewRow As Long
With Me.MSFlexGrid1
If .Col = 8 And .Row <> OldRow Then
NewRow = .Row
.Row = OldRow
Set .CellPicture = Nothing ' Don't really need LoadPicture("c:\icon\blank.ico")
.Row = NewRow
Set .CellPicture = LoadPicture("c:\icon\flip.ico")
OldRow = NewRow
End If
End With
End Sub
-
- PlatinumLounger
- Posts: 4481
- Joined: 26 Apr 2010, 17:36
Re: add ico in msflexgrid
GOOD idea to add new column!SpeakEasy wrote: ↑28 Oct 2023, 14:37<edit: ah, looks like our posts crossed)
You need Set
I'd slightly modify Han's code to:
But bear in mind that in the msflexgrid control neither the icon or text in the cell know anything about each other, so you'll need to figure out a way to position the text appropriately when the icon is inserted. The simple alignment settings available for the pricture and/or the text alone may not be sufficient. Personally, I'd probably introduce an extra column just to display the icon.Code: Select all
Private Sub MSFlexGrid1_Click() Static OldRow As Long Dim NewRow As Long With Me.MSFlexGrid1 If .Col = 8 And .Row <> OldRow Then NewRow = .Row .Row = OldRow Set .CellPicture = Nothing ' Don't really need LoadPicture("c:\icon\blank.ico") .Row = NewRow Set .CellPicture = LoadPicture("c:\icon\flip.ico") OldRow = NewRow End If End With End Sub