Subj : Printing 2D array in List Box with alignment To : borland.public.cpp.borlandcpp From : Nirvana Date : Sat Apr 30 2005 03:59 pm Hi All, If it's not the place for such question then kindly show me the door of right NG. I want to print an array of integers with right alignment something like this: 23 45 7 7 2 34 10 23 9 I'm using AnsiString to achive this but it seems it doesn't doing the right thing. Following is the code: void __fastcall TForm_EM::print2DArray( int** ptr, int maxRow, int maxCol) { AnsiString outString; AnsiString temp; for(int row = 0; row < maxRow; row++) { for(int col = 0; col < maxCol; col++) { temp = ""; temp.sprintf("%3d",*(ptr+maxCol*row+col)); outString+= temp; } ListBox_Debug->AddItem(outString,this); outString = ""; } } In console based application this can be done easily with cout.setf(ios:right) and setw(3) functions Any help? cheers Nirvana .