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

Show TListBox Items in Multiple Columns

By , About.com Guide

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
Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  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.