Page 1 of 2 12 LastLast
Results 1 to 40 of 78

Thread: listview table colors

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    Question listview table colors

    Is there a way to change the standard listview table colors? i know i can change the background and forecolors..

    but i want to go from this standard look:
    Name:  untitled1.jpg
Views: 461
Size:  10.1 KB

    to something more like this:
    Name:  untitled.PNG
Views: 867
Size:  2.1 KB

    with the black borders around everything... i don't see anything about border colors.. also don't see anything about the column headers either... so is there like a code for all this? or a module?

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    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

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    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:

  5. #5
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    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

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    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.

  7. #7
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    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

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    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...

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    Re: listview table colors

    i tried that before and that didn't work...

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    Re: listview table colors

    Quote Originally Posted by Arnoutdv View Post
    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...

  11. #11
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    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

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    Re: listview table colors

    Quote Originally Posted by Arnoutdv View Post
    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...

  13. #13
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: listview table colors

    Then don't fill the textmatrix in some other part of the code.

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    Re: listview table colors

    Quote Originally Posted by Arnoutdv View Post
    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.

  15. #15
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: listview table colors

    Check the help :-)

    .CellPictureAlignment ...

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    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...

  17. #17
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,046

    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.

  18. #18
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: listview table colors

    Quote Originally Posted by Maximillion View Post
    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.

  19. #19

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    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.

  20. #20
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    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).

  21. #21
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    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).

  22. #22
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  23. #23
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    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).

  24. #24

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    Re: listview table colors

    just for clarity.. all the images are in a IMAGELIST and currently are not the same size but will be...

  25. #25
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    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).

  26. #26
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    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).

  27. #27
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: listview table colors

    This is not quite right....be back in a bit
    Sam I am (as well as Confused at times).

  28. #28
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    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).

  29. #29

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    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.

  30. #30
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    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).

  31. #31

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    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.

  32. #32

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    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

  33. #33
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    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).

  34. #34

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    Re: listview table colors

    it's ALL intertwined.... from colors, width, height, images - (NO TEXT.. images replace the text).. just keeping everything in 1 topic... this way i can ask and receive help within the same objective.. otherwise we all will get lost and confused... easier to follow 1 thread rather than 100 on the same objective...

    1.) colors Name:  completeclear.gif
Views: 292
Size:  315 Bytes
    2.) show images instead of text in cells Name:  completeclear.gif
Views: 292
Size:  315 Bytes
    3.) sizes - we working on it..
    4.) show text and gender icon in same cell side by side - not there yet
    5.) show 2 images side by side in same cell - not possible -must be 1 image Name:  completeclear.gif
Views: 292
Size:  315 Bytes

    see??


    #31 was done in PAINT to show what it is i am trying to accomplish with the width and height and images - (all uniformed and even)... the opening post was about the bgcolors so it all looks good,,, and it's a FLEXGRID.. and the only reason i am going with it is because of the ease of colors... what i don't like so far about the flexgrid.. maybe it's just me.. is you can click each cell vs a single row as i have done in the past with a listview.. with the listview i did double click and right click.. but it was for the whole row.. not sveperate cells... this i do need as well.. but maybe it's just me not knowing how nor have ever used a flexgrid... but we'll get to that much later...
    Last edited by Maximillion; Jan 16th, 2021 at 06:25 PM.

  35. #35
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    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

  36. #36

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    Re: listview table colors

    Quote Originally Posted by Arnoutdv View Post
    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.

  37. #37
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: listview table colors

    Couldn't you merge 2 images together (on the fly with graphics APIs) then assign that as the single image?

  38. #38

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    Re: listview table colors

    of course i can..

  39. #39
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: listview table colors

    make this easy -- zip your project and attach
    Sam I am (as well as Confused at times).

  40. #40

    Thread Starter
    Lively Member
    Join Date
    Dec 2020
    Posts
    99

    Re: listview table colors

    Quote Originally Posted by SamOscarBrown View Post
    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.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width