Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Change the default color of a specific item in a ListView

193 views
Skip to first unread message

George Tritsos

unread,
Oct 19, 2013, 3:50:55 PM10/19/13
to
Hi all,
I want to change the color of a specific item in a List View.

e.g. 2nd line 1st column and 3rd line 1st column red color

Is it possible?

Thanks in advance
George

Wolfgang Riedmann

unread,
Oct 20, 2013, 3:09:42 AM10/20/13
to
Hi George,

> I want to change the color of a specific item in a List View.
>
> e.g. 2nd line 1st column and 3rd line 1st column red color
>
> Is it possible?


yes, this is possible using ownerdraw and the Windows API, but not with
the basic VO classes.

Wolfgang


--

D.J.W. van Kooten

unread,
Oct 20, 2013, 3:15:41 AM10/20/13
to
On Sat, 19 Oct 2013 12:50:55 -0700 (PDT), George Tritsos
<George...@yahoo.gr> wrote:

Hello George,

> I want to change the color of a specific item in a List View.
>
>e.g. 2nd line 1st column and 3rd line 1st column red color
>
>Is it possible?
>
Yes. First you will need the Common Control MEF (if you don't have
that somewhere, drop me a mail and I'll send it to you). After that it
will look something like this, in the ControlNotify of your LV. For a
so called iSubitem (= a column) I inspect the content and colour it
green or red.

METHOD ControlNotify(oEvent) CLASS ToDoExplorer
LOCAL pNMCustomDraw AS _WINNMLVCUSTOMDRAW
LOCAL dwDrawStage AS DWORD
LOCAL dwItem AS DWORD
LOCAL oItem AS ListViewItem
LOCAL dCode AS DWORD

dCode := oEvent:NotifyCode IF dCode = NM_CUSTOMDRAW .AND.
IsInstanceOf( oEvent:control, #LISTVIEW )
pNMCustomDraw := PTR( _CAST , oEvent:lParam )
dwDrawStage := pNMCustomDraw.nmcd.dwDrawStage
DO CASE
CASE dwDrawStage = CDDS_PREPAINT
SELF:EventReturnValue := CDRF_NOTIFYITEMDRAW
CASE _AND( dwDrawStage , CDDS_ITEMPREPAINT ) > 0
dwItem := pNMCustomDraw.nmcd.dwItemSpec
DO CASE
// dwItem contains the 0-based item
and
// pNMCustomDraw.iSubItem contains the
0-based subitem == column
CASE pNMCustomDraw.iSubItem==1
// 1 is my first column
oItem:=SELF:oLV:GetNextitem(LV_GNIBYITEM,,,,,dwItem)
pNMCustomDraw.clrText := DWORD(RGB( 0 , 0 , 0 )) // black
IF oItem:GetText( #DONE)=Vt(CLM_YES,"Yes")
pNMCustomDraw.clrTextBk := DWORD(RGB( 150 , 220 , 160 ) ) //
Light green
ELSE
pNMCustomDraw.clrTextBk := DWORD(RGB( 250 , 130 , 130 )) //l
Light red
ENDIF
ENDCASE
RETURN SELF:EventReturnValue
ENDIF
RETURN SUPER:ControlNotify( oEvent )


Dick
Message has been deleted

George Tritsos

unread,
Oct 20, 2013, 3:36:02 AM10/20/13
to
Hi Dick

My email is "George...@yahoo.gr"

Thanks
George

George Tritsos

unread,
Oct 21, 2013, 4:15:41 AM10/21/13
to
Hi Dick,

I received your email with MEF file and now it's time for work.

Million thanks
George

Message has been deleted

Fabio Romling Rotheia

unread,
Oct 21, 2013, 9:43:34 AM10/21/13
to
Hi George! Hi Dick!

Can you guys also send me the MEF?
my e-mail is: fa...@kosmosdistribuidora.com.br

Thanks,

Fabio.

D.J.W. van Kooten

unread,
Oct 21, 2013, 12:05:40 PM10/21/13
to
On Mon, 21 Oct 2013 06:37:03 -0700 (PDT), Fabio Romling Rotheia
<fa...@kosmosdistribuidora.com.br> wrote:

Hello Fábio,

>Can you also send me the MEF file?
>fa...@kosmosdistribuidora.com.br
>
Done!

Dick

jmmnor...@gmail.com

unread,
Oct 21, 2013, 2:46:29 PM10/21/13
to
I would appreciate the MEF too. (jmm...@gmail.com) Thanks.

James

Paulo Oliveira

unread,
Oct 29, 2013, 5:44:50 AM10/29/13
to
Can you also send me the MEF
Thanks

Paulo

antos...@gmail.com

unread,
Oct 29, 2013, 7:20:30 AM10/29/13
to
Hi George! Hi Dick!

Can you guys also send me the MEF?
my e-mail is: anto...@mail.ru

Thanks,

Sergey A

D.J.W. van Kooten

unread,
Oct 29, 2013, 3:50:47 PM10/29/13
to
On Mon, 21 Oct 2013 06:43:34 -0700 (PDT), Fabio Romling Rotheia
<fa...@kosmosdistribuidora.com.br> wrote:

>
>Can you guys also send me the MEF?
>my e-mail is: fa...@kosmosdistribuidora.com.br
>
>Thanks,
>
Hello Fabio,

Sure! Just sent it to you and Sergey.

Dick
0 new messages