Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ListBox, how to?

Posted on 2013-12-11
4
Medium Priority
?
336 Views
Last Modified: 2014-01-21
Hello Guys,

I need a clue how to do something like this:

I have a lisbox on my form with 20 lines, some lines are painted in color font clRed and other clblack.

How can I count how many lines I have in my listbox in clred color font?

Thanks
Alex
0
Comment
Question by:hidrau
[X]
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
4 Comments
 
LVL 27

Accepted Solution

by:
Sinisa Vuk earned 2000 total points
ID: 39713344
Each listbox item is stored in TStrings list. Item can be stored in with some additional parameter as TObject (integer, like Tcolor is integer too):
listbox.Items.AddObject('item in red', TObject(clRed));
listbox.Items.AddObject('item in red', TObject(clBlack));
....

Open in new window


later you can check for this additional parameter (and even check when drawing in some of OnDraw events):
for i:=0 to listbox.Items.Count-1 do
begin
  if listbox.Items.Objects[i] = TObject(clRed) then ...
  if listbox.Items.Objects[i] = TObject(clBlack) then
end;

Open in new window

0
 
LVL 19

Expert Comment

by:MerijnB
ID: 39713429
How did the items become red? Probably because you painted them red? From what information did you decide to make them red? Can't you look in that information to count?
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 39713478
or the other way around:

how did you paint them black > the_number_of_blacks
to find the reds: listbox.count - the_number_of_blacks
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 39796608
thanks for the idea :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

722 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