Changing the text colour of a single row in a TListView

Posted on 2004-08-30
Last Modified: 2013-11-17
I am writing a serial comms chat program and I need to have the outgoing messages a different colour to the incoming messages.  I am using a TListView in Borland C++ Builder 6 to display the messages.  Whenever I have a new message come in with the different colour it changes all of the rows in the TListView to that colour, I just want to change that one row.  Do you know how I can change the text colour of each row seperately without modifying the text colour of the whole ListView?.. I am getting very close to the end of this project and didn't realise that the TListView had this restriction until now, any help would be greatly appreciated.....
Question by:sabrE7
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 16

Expert Comment

by:George Tokas
ID: 11929592
I suppose that you change the color property when you are getting a message from a TSocket and you are about to display it to the TListView component.
Is the TListView component needed or you can use another component to do the job?
If it is not needed then you can use a TMemo instead and there (as I know of) the functonality you want will work without any code changes.


Author Comment

ID: 11929768
I change the colour property when I receive/transmit a message to/from a mySQL database.  The TListView is definately required as there is a few column's required for each message, these columns hold the Time RX/TX and whether the message has been acknowledged.  The TListView is now firmly entrenched in the code in for both the Main Message Log and for viewing database queries.  I have all of the TListView functionality accessible from a seperate class, so it will be simple to modify.  I require each of the messages to be distinctly seperated, the TListView allows this in 'vsReport' mode with the grid pattern.  
LVL 16

Accepted Solution

George Tokas earned 500 total points
ID: 11929854
I understand all those and I can see how you have worked with your project.
The fact is that you can not change the font or color of a TListItem inside the TListView.
So you have to think how you will display the message with the properties you want (color or something else). I suggest to use a TMemo to display the message with all those you want. The Lines property of TMemo is an AnsiString and so you can modify the appearance.
Also you can add the information you want (time, ack, etc.) in front or trailing on the AnsiString to be displayed.


Author Comment

ID: 11931032
Well that certainly darkens my day....I have played around with the TMemo component and it would work though I would have to rewrite a considerable amount of code.  I have found a component that is designed for Delphi 7 which would do what I want, though would I be able to use this component in BCB 6, because as I understand it, most of the BCB6 components are originally written in Pascal.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What is an NDK ? 3 107
Java eclipse error 2 77
How to find missing packages when using Netbeans IDE 8.1 ? 19 84
C#  WebForms or MVC 4 136
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project ( automates most of the tasks discussed in this article. You can even fin…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question