Board index » delphi » How do I organize a ComboBox or ListBox? **********

How do I organize a ComboBox or ListBox? **********

Quote
Padre wrote:

> I want to enter a string of five items into a ComboBox preferably or a
> ListBox if necessary.   i.e.

> Doe, Joe      00203    M    Sales     212

> How do I get the items to be columnar so that the next string will
> line up straight and look decent?

        One way is to write a StringPad function.  Here is
        a stub...

        function StringPad(Str : String; Spaces : Integer) : String;
        var
           Padded   : String;
           i        : Integer;
        begin
           Padded := '';
           for i := 1 to NumDigits - Length(Value) do
              Padded := Padded + ' ';
           Value := Value + Padded;
           Result := Value;
        end;

        Then when you are adding your columns just call it
        like this...

        var
          StrToAdd  : String;
          LastName  : String;
          FirstName : String;
          EmployeeId: String;
        begin
          StrToAdd :=   StringPad(LastName, 25) +
                        StringPad(FirstName,25) +
                        StringPad(EmployeeId, 10);
          ListBox.Items.Add(StrToAdd);
        end;

        brant
        ...

 

Re:How do I organize a ComboBox or ListBox? **********


I want to enter a string of five items into a ComboBox preferably or a
ListBox if necessary.   i.e.

Doe, Joe      00203    M    Sales     212  

How do I get the items to be columnar so that the next string will
line up straight and look decent?

Other Threads