Create Columns in a Listbox

Even if you use tabs to try to align various parts entries in a listbox, you will not have straight columns even if everything in a given column has about the same length. To get columns with this type of data, you have to switch to a monospace type such as Courier new. Even this is no help if entries in any column but the last have different lengths. If this is the case, I suggest that in addition to the monospace type (which is essential), create a function like the tab function shown here. Whereever you would have used a tab, call tab with the string in the current column and the total size (text plus spaces) of the column in characters.

String tab(const  String &s,int  columnSize)
{
   String result ="";
   for (int i = 0; ireturn  result;
}

String Item::getDescription()
{
   String result;
   result = _name + tab(_name,30)+_title;
   return  result;
}

In this problem, both _name and _title are String members of item.

To get a complete copy of this simple program click here.