Making a logbook using editbox for entries that fill a listbox. I have two enter buttons. One would enter line in Red one in Black but I don't know how to change the font color in the listbox. My first pascal program and this is the last step for completion.:( I'm total noob so please explain clearly.

You cannot simply change the font per line in a TListBox, without adding some additional coding.

Yes I know. Change the event of ondrawItem. But can it be done with an easy bit of code. I know how to color an individual line or every other line but not how to tie the color to anything but the index.

Edited 4 Years Ago by BorisSobad: n/a

Well, if you know that already then it is relatively simple. The Items property of a TListBox has an AddObject method. You can use it when adding your string like this:

// clRed is an Integer, and you just cast it to an object
// so it can be added alongside your item text.
ListBox1.Items.AddObject('item', TObject(clRed));

// In your OnDrawItem (color is a TColor variable)
// where i is the index of your current item.
color := TColor(ListBox.Items.Objects[i]);

Edited 4 Years Ago by pritaeas: n/a

This question has already been answered. Start a new discussion instead.