Changing cell text color in and out of CellTextPaint

  1. last week

    This application takes images dropped onto a listbox, and pareses out metadata throughout the listbox.
    I want to change the color of text in a certain cell, if the text does not = "Adobe RGB (1998)"

    I have this bit of code:

    select case column
    case 6
        if lstBoxImages.cell(lstboximages.lastindex, 6) <> "Adobe RGB (1998)" Then
            g.ForeColor = &cff0000
        end if
    end Select

    When I put this code into the CellTextPaint method. It works... to an extent.
    Once I hit an image that does not have the correct Profile ("Adobe...") it changes the profile to Red as expected.
    But if I add another image after, the text remains black as it should, but then also changes the one before it back to black. Which seems correct since I'm running a case on column 6...

    So then I thought the code should instead be placed inside the for loop where I'm adding the image metadata to the listbox. Well, that doesn't work at all.
    And if I then get rid of the case select, I then get a NilObjectException on g.ForeColor = &cff0000.

    Kind of stumped.

    @michael m lstboximages.lastindex

    You probably want to use the row parameter to the event instead of the last index (i.e. the most recently added row).

  2. Andrew L

    May 14 Answer San Francisco, CA, USA

    @michael m lstboximages.lastindex

    You probably want to use the row parameter to the event instead of the last index (i.e. the most recently added row).

  3. @Andrew L You probably want to use the row parameter to the event instead of the last index (i.e. the most recently added row).

    How do I express the most recently added row?

  4. @Andrew L You probably want to use the row parameter to the event instead of the last index (i.e. the most recently added row).

    Nevermind. Got it. Thank you @Andrew L !

or Sign Up to reply!