Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming

Show TListBox Items in Multiple Columns

By Zarko Gajic, About.com

TListBox Columns

TlistBox Columns

Delphi's TListBox control displays a collection of items in a scrollable list.

By design, a listbox displays its items in one column.

If you want to display several items in one row, thus have multiple columns in a list box, you can use the next approach:

Set the TabWidth property - it specifies the width of the columns in pixels.

When you add items to the list box, separate the columns with '^I', that is capital "i", like in:

begin
  ListBox1.Items.Add('First'^I'Second'^I'Third') ;
  ListBox1.Items.Add('C1R1'^I'C2R1'^I'C3R1') ;
  ListBox1.Items.Add('C1R2'^I'C2R2'^I'C3R2') ;
  ListBox1.Items.Add('C1R3'^I'C2R3'^I'C3R3') ;
  ListBox1.Items.Add('C1R4'^I'C2R4'^I'C3R4') ;
  ListBox1.Items.Add('C1R5'^I'C2R5'^I'C3R5') ;
  ListBox1.Items.Add('C1R6'^I'C2R6'^I'C3R6') ;
  ListBox1.Items.Add('C1R7'^I'C2R7'^I'C3R7') ;
  ListBox1.Items.Add('C1R8'^I'C2R8'^I'C3R8') ;
  ListBox1.Items.Add('C1R9'^I'C2R9'^I'C3R9') ;
end;
Delphi tips navigator:
» Hide/Show Tray icons
« Get text from the control at pos x,y on screen
Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Using VCL Components
  5. TListBox
  6. Show TListBox Items in Multiple Columns

©2009 About.com, a part of The New York Times Company.

All rights reserved.