• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

Changing the text colour of a single row in a TListView

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.....
0
sabrE7
Asked:
sabrE7
  • 2
  • 2
1 Solution
 
George TokasCommented:
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.
Question:
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.

gtokas.
0
 
sabrE7Author Commented:
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.  
0
 
George TokasCommented:
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.

gtokas.
0
 
sabrE7Author Commented:
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.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now