-
Jan 14th, 2021, 12:46 AM
#1
Thread Starter
Lively Member
-
Jan 14th, 2021, 01:44 AM
#2
Re: listview table colors
Most easy way is to use a MS(H)FlexGrid.
Otherwise you have to use subclassing. There are some samples on this forum for coloring a ListView
-
Jan 14th, 2021, 08:09 AM
#3
Re: listview table colors
-
Jan 14th, 2021, 02:02 PM
#4
Thread Starter
Lively Member
Re: listview table colors
what are the pro's and con's of listview and flexgrid other than the custom colors which has been stated and tested...
LISTVIEW:
pro's:
con's
FLEXGRID:
pro's:
1.) custom colors
con's:
-
Jan 14th, 2021, 02:10 PM
#5
Re: listview table colors
See the various samples in this thread.
And the header is changed virtually identically to the items: [VB6] Change ListView Header Color, Back Color, and Font
-
Jan 15th, 2021, 06:16 AM
#6
Thread Starter
Lively Member
Re: listview table colors
i'm trying to get a picture to show instead of the TEXT from the database in a cell...
like if type1 value is say "Flying" then show a picture instead of the word "Flying"...
Code:
Private Sub callDb(theSetToUse)
grid1.Clear
setupGridHeaders
Label2.Caption = theSetToUse
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = cnn
cmd.CommandText = "Select * from allsets where setName = '" & theSetToUse & "' order by pokedexnumber"
Set rs = cmd.Execute
Dim i As Integer
i = 1
Do While Not rs.EOF
grid1.Rows = grid1.Rows + 1
grid1.Row = i
grid1.TextMatrix(i, 0) = rs!pokeDexNumber
grid1.TextMatrix(i, 1) = rs!cardname
grid1.TextMatrix(i, 2) = rs!type1
'...................................................................................................................................................
If rs("type1") = "Grass" Then
grid1.TextMatrix(i, 2) = Image1.Picture
End If
'...................................................................................................................................................
If Not IsNull(rs!type2) Then
grid1.TextMatrix(i, 3) = rs!type2
End If
grid1.TextMatrix(i, 4) = rs!Rarity
grid1.TextMatrix(i, 5) = rs!PSA
grid1.TextMatrix(i, 6) = rs!Qty
grid1.TextMatrix(i, 7) = rs!cardValue
If Not IsNull(rs!notes) Then
grid1.TextMatrix(i, 8) = rs!notes
End If
i = i + 1
rs.MoveNext
Loop
End Sub
but nothing i do works.. always an error.. i do want to do something like CASES because there are various type1 text values.... instead of showing me the picture it changed the word "Flying" to a bunch of numbers....
Last edited by Maximillion; Jan 15th, 2021 at 07:03 AM.
-
Jan 15th, 2021, 06:46 AM
#7
Re: listview table colors
This does maybe not what you hope it would do
Code:
If grid1.TextMatrix(i, 2) = rs!type1 = "Flying" Then
grid1.TextMatrix(i, 2) = rs!type1 = Image1.Picture
End If
What do you want it do? In just words, not in code
Further, to assign a picture to a cell you have to use the .CellPicture property
-
Jan 15th, 2021, 06:51 AM
#8
Thread Starter
Lively Member
Re: listview table colors
i tried the cellpicture property but all i get is an error...
i want it to show an image INSTEAD of the word "flying" that database has a value...
so, if value for type1 is "Flying" - do NOT display the word "Flying", but instead show image1.picture
so, if value for type1 is "Grass" - do NOT display the word "Grass", but instead show image2.picture
and so on...
-
Jan 15th, 2021, 06:53 AM
#9
Thread Starter
Lively Member
Re: listview table colors
i tried that before and that didn't work...
-
Jan 15th, 2021, 06:54 AM
#10
Thread Starter
Lively Member
Re: listview table colors
Originally Posted by Arnoutdv
This does maybe not what you hope it would do
Code:
If grid1.TextMatrix(i, 2) = rs!type1 = "Flying" Then
grid1.TextMatrix(i, 2) = rs!type1 = Image1.Picture
End If
i tried that before and it didn't work...
-
Jan 15th, 2021, 07:03 AM
#11
Re: listview table colors
Try this (air code)
Code:
Select Case rs("type1")
Case "Grass"
Grid1.Col = 2: Grid1.Row = i: Set Grid1.CellPicture = Image2.Picture
Case "Flying"
Grid1.Col = 2: Grid1.Row = i: Set Grid1.CellPicture = Image1.Picture
Case Else
Grid1.TextMatrix(i, 2)= rs("type1")
End Select
-
Jan 15th, 2021, 07:05 AM
#12
Thread Starter
Lively Member
Re: listview table colors
Originally Posted by Arnoutdv
Try this (air code)
Code:
Select Case rs("type1")
Case "Grass"
Grid1.Col = 2: Grid1.Row = i: Set Grid1.CellPicture = Image2.Picture
Case "Flying"
Grid1.Col = 2: Grid1.Row = i: Set Grid1.CellPicture = Image1.Picture
Case Else
Grid1.TextMatrix(i, 2)= rs("type1")
End Select
well, it DOES show the image i want.. BUT, it also shows the text behind the picture which i don't want.... i also tryied commenting out the CASE ELSE - still shows the text behind the picture...
-
Jan 15th, 2021, 07:07 AM
#13
Re: listview table colors
Then don't fill the textmatrix in some other part of the code.
-
Jan 15th, 2021, 07:09 AM
#14
Thread Starter
Lively Member
Re: listview table colors
Originally Posted by Arnoutdv
Then don't fill the textmatrix in some other part of the code.
yep, had to comment out
Code:
'grid1.TextMatrix(i, 2) = rs!type1
right above it... ty for your help! oh, also.. is there a way to center the image in the cell.. right now it's left justified...
grid1.ColAlignment(i, 2) = grid1AlignCenterCenter ' doesn't work...
Last edited by Maximillion; Jan 15th, 2021 at 07:19 AM.
-
Jan 15th, 2021, 07:21 AM
#15
Re: listview table colors
Check the help :-)
.CellPictureAlignment ...
-
Jan 15th, 2021, 07:24 AM
#16
Thread Starter
Lively Member
Re: listview table colors
k... also, it doesn't show the full image... a little of the bottom of it is not showing.. i thought the image would make the entire row height bigger to the size of the image.. oh well.. ty for all your help...
-
Jan 15th, 2021, 07:56 AM
#17
Re: listview table colors
see if you can use some of this
Code:
Private Sub Command1_Click()
Dim myPic As StdPicture
Dim Faktor As Single
Dim x As Single, y As Single
Dim Row As Long, Col As Long
Row = 2
Col = 1
With MSFlexGrid1
.RowHeight(Row) = 800
.ColWidth(Col) = 500
End With
Set Picture1.Picture = LoadPicture("E:\testfolder\p10.jpg")
Set myPic = Picture1.Picture
x = Picture1.Width
y = Picture1.Height
Faktor = 1
With MSFlexGrid1
Faktor = .RowHeight(Row) / y
If Faktor > (.ColWidth(Col) / x) Then
Faktor = (.ColWidth(Col) / x)
End If
.Row = Row
.Col = Col
End With
Debug.Print Picture1.Width, Picture1.Height
Set Picture1.Picture = Nothing
Picture1.Width = x * Faktor - 2 * Screen.TwipsPerPixelX
Picture1.Height = y * Faktor - 2 * Screen.TwipsPerPixelY
Picture1.PaintPicture myPic, 0, 0, x * Faktor - 2 * Screen.TwipsPerPixelX, _
y * Faktor - 2 * Screen.TwipsPerPixelY
Set MSFlexGrid1.CellPicture = Picture1.Image
Debug.Print Picture1.Width, Picture1.Height
Set Picture1.Picture = Nothing
Set myPic = Nothing
End Sub
HTH
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Jan 15th, 2021, 10:15 AM
#18
Re: listview table colors
Originally Posted by Maximillion
k... also, it doesn't show the full image... a little of the bottom of it is not showing.. i thought the image would make the entire row height bigger to the size of the image.. oh well.. ty for all your help...
The column width and row height are never changed to match the data.
All code for resizing has to be done by the programmer.
-
Jan 15th, 2021, 11:25 AM
#19
Thread Starter
Lively Member
Re: listview table colors
@ ChrisE - ty, i'll have to look a little more closely at that.. seems a little long for my project.. so'll i'll have to break that down
@ Arnoutdv - oh, i thought it was an auto thing due to filled content.. ie: image..
ok, i will play with this for a bit later after work... ty
i want to change it in here if i can... so they are all the same height.. but width differently...
Code:
Private Sub setupGridHeaders()
grid1.TextMatrix(0, 0) = "#"
grid1.TextMatrix(0, 1) = "Name"
grid1.TextMatrix(0, 2) = "Type 1"
grid1.TextMatrix(0, 3) = "Type 2"
grid1.TextMatrix(0, 4) = "Rarity"
grid1.TextMatrix(0, 5) = "PSA"
grid1.TextMatrix(0, 6) = "QTY"
grid1.TextMatrix(0, 7) = "Card Value"
grid1.TextMatrix(0, 8) = "Notes"
grid1.ColWidth(8) = 2200
grid1.Rows = 1
End Sub
Last edited by Maximillion; Jan 15th, 2021 at 11:32 AM.
-
Jan 15th, 2021, 02:40 PM
#20
Re: listview table colors
Believe you will have to use the .RowHeight property (this will change, obviously, the height of all cells in that row)
EDIT: for example: grid1.rowHeight(5) = 1000 where 5 is the row you have the picture, and 1000 is the height of the image
Last edited by SamOscarBrown; Jan 15th, 2021 at 02:44 PM.
Sam I am (as well as Confused at times).
-
Jan 15th, 2021, 03:07 PM
#21
Re: listview table colors
Now, if you ARE using a flexgrid...you have load an image control (Stretch property = True) so you can set the Row and Col height and width of the image you are getting from your DB...like, in this example (loading from app.path rather than a db). (You can have the image visible property set to false):
Code:
Image1.Picture = LoadPicture(App.Path & "\capture.jpg")
Grid1.Row = 1
Grid1.Col = 3
Grid1.RowHeight(1) = Image1.Height
Grid1.ColWidth(3) = Image1.Width
Set Grid1.CellPicture = LoadPicture(App.Path & "\capture.jpg")
This will show the entire image in the cell and the row and col heights and widths will be accommodated.
Sam I am (as well as Confused at times).
-
Jan 15th, 2021, 04:11 PM
#22
Re: listview table colors
No need to load the same image twice, dump one copy into an extra control, etc.
Just load it once and scale the StdPicture object's Height and Width properties as required.
-
Jan 15th, 2021, 06:14 PM
#23
Re: listview table colors
@dile....how? If the images are of different size, but I (excuse me, the OP) want(s) to have all of them the same size in the grid, how is that done...how do you get the H and W if it is not loaded into an 'extra' control (but, BTW, what does that really matter?--an invisible Image control?
Are you saying load the picture in the grid and then scale the cell to the size of the image? That would not work, would it, if images are of varying sizes...I would think OP would like (for appearance sake) all images in the grid to appear to be the same size.
Sammi
Sam I am (as well as Confused at times).
-
Jan 16th, 2021, 05:43 AM
#24
Thread Starter
Lively Member
Re: listview table colors
just for clarity.. all the images are in a IMAGELIST and currently are not the same size but will be...
-
Jan 16th, 2021, 08:02 AM
#25
Re: listview table colors
Then you know, in advance, the HT and WD of the images before they are placed in a grid, correct? If so, make the row/col numbers to match that HT and WD.
Sam I am (as well as Confused at times).
-
Jan 16th, 2021, 08:41 AM
#26
Re: listview table colors
Here's an example of putting images from an imagelist into an MSFlexGrid: (Note, set your height and width in the imagelist control at design time---these will be used to make the row and col the correct size. In this example, I am using column #3 (of a 5 column grid) and rows 1 and 2 of a grid with row(0) as fixed and set up in the IDE as a 2-row Grid).
Code:
Dim i As Integer
Grid1.Col = 3
Grid1.ColWidth(3) = ImageList1.ImageWidth
For i = 0 To ImageList1.ListImages.Count - 1
Grid1.Rows = i + 2
Grid1.Row = i + 1
Set Grid1.CellPicture = ImageList1.ListImages(i + 1).Picture
Grid1.RowHeight(Grid1.Row) = ImageList1.ImageHeight
Next i
EDIT: Of course this assumes you have your imagelist already populated with images.
AND, it precludes having to use any 'extra' control as you already have one---the imageList control
Last edited by SamOscarBrown; Jan 16th, 2021 at 08:48 AM.
Sam I am (as well as Confused at times).
-
Jan 16th, 2021, 08:56 AM
#27
Re: listview table colors
This is not quite right....be back in a bit
Sam I am (as well as Confused at times).
-
Jan 16th, 2021, 09:20 AM
#28
Re: listview table colors
Welllllll....having a little difficulty here setting column width and height ...gotta run now, will look at it later...
Appears I may have to set the image dimensions to the column dimensions and not vice-versa. Got a Bible study, so gotta bow out for now.
Sam
Sam I am (as well as Confused at times).
-
Jan 16th, 2021, 02:44 PM
#29
Thread Starter
Lively Member
Re: listview table colors
just so there is no misunderstanding of what i'm trying to accomplish... but i think everyone here gets it..
Attachment 179886
there's 2 more cells that i did not show per row.. but this is what i'm trying to accomplish...
i dunno why it's not showing like my other pics in the first post...
Last edited by Maximillion; Jan 16th, 2021 at 02:50 PM.
-
Jan 16th, 2021, 03:03 PM
#30
Re: listview table colors
Don't think "I" do...
also, that is an invalid attachment...take a picture of it and add it (a jpg would be just fine)
Sam I am (as well as Confused at times).
-
Jan 16th, 2021, 03:15 PM
#31
Thread Starter
Lively Member
Re: listview table colors
what do you mean "you don't think you do"? even rows/cells/same size pics in the row... to me it's very clear.. each cell is the same size... i don't think it can be made more clearer lol
Last edited by Maximillion; Jan 16th, 2021 at 03:19 PM.
-
Jan 16th, 2021, 03:22 PM
#32
Thread Starter
Lively Member
Re: listview table colors
anyways, i have 10k card entries to put into a database and i'm only at 2k entries atm.. so, i'll be working on that for awhile.. i'll check back on this in a bit
-
Jan 16th, 2021, 03:39 PM
#33
Re: listview table colors
got that....(I think). But because this thread has evolved from coloring cells, to an imagelist, to not showing text and image in same cell, to a database, I have gotten lost (sorry, MY fault). So, I now see that image you posted in #31. How do you want to change that? Also, is that a flexgrid or a listview?
Sam I am (as well as Confused at times).
-
Jan 16th, 2021, 05:38 PM
#34
Thread Starter
Lively Member
-
Jan 16th, 2021, 06:11 PM
#35
Re: listview table colors
2 images in a cell is not possible.
A cell can only contain a single image.
So you have to create new images on the fly if you need to combine them
-
Jan 16th, 2021, 06:21 PM
#36
Thread Starter
Lively Member
Re: listview table colors
Originally Posted by Arnoutdv
2 images in a cell is not possible.
A cell can only contain a single image.
So you have to create new images on the fly if you need to combine them
i was expecting that... was just curious if i could call 2 images or more in a cell
well.. we 3 out of 5...
Last edited by Maximillion; Jan 16th, 2021 at 06:27 PM.
-
Jan 16th, 2021, 08:29 PM
#37
Re: listview table colors
Couldn't you merge 2 images together (on the fly with graphics APIs) then assign that as the single image?
-
Jan 17th, 2021, 11:03 AM
#38
Thread Starter
Lively Member
Re: listview table colors
of course i can..
-
Jan 17th, 2021, 08:15 PM
#39
Re: listview table colors
make this easy -- zip your project and attach
Sam I am (as well as Confused at times).
-
Jan 17th, 2021, 08:29 PM
#40
Thread Starter
Lively Member
Re: listview table colors
Originally Posted by SamOscarBrown
make this easy -- zip your project and attach
my project is too detailed and way past the beginning stages.. i put in way too much time, effort and lots of loss of sleep designing, graphics, filling the database with over 4k entries and everything else.. i'm not just gonna hand over the project in a .zip file.. not happening.
however, i can create a lame project that mimics what i'm trying to do... and besides SAM, i already PM'd you awhile back the project - but the current one has a lot more details and all.. so i cannot just zip my project and attach it and let everybody's hands get on it... just can't do it.. sorry. my work and time is too valuable this far into the project... if it was a 1 on 1 type of project - i may have been into sharing the current project version with an NDA.. but that's not the case..
Last edited by Maximillion; Jan 17th, 2021 at 11:51 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|