Listbox Row Selection

Greetings all.

I’m hoping that somebody out there may have come across this, so here goes.

Is it possible to override the default drawing for a selected row in a Listbox? For example, in my Win7 app, my listbox highlights selected rows with an all blue row with white text. I have colour coded text and background colours which I wish to not hide when then user selects a row.

I want to the selected row to be say a red rectangle around the whole row.

Does the CellTextPaint and CellBackgroundPaint events hold the answer?

Any ideas?

Cheers
Grant

Yeap, both these events hold the answer. In CellBackgroundPaint check if the row is the selected row, and then paint accordingly. If you want the text to be of a specific color, then return True in CellTextPaint (which means that the listbox will not handle the text drawing) and add your text drawing code in CellBackgroundPaint.

Yes.

Use CellBackgroundPaint to set the outline and background colour.

Remember to return True from the event to stop the default colouring.

Simon.

Thanks for your timely input Ashot & Simon.

Cheers
Grant