Page 1 of 1

align a table created from a tab separated stringlist

Posted: Sat Sep 11, 2010 4:23 pm
by jclaes
Hi,

I was able to create a table using following code

Code: Select all

     .....
     Table := TRVTableItemInfo.CreateEx(Rows, Cols, RVData);
     Table.BorderWidth := 0;
     Table.CellBorderWidth := 0;
     for RowCounter := 0 to Fields.Count-1 do
      begin
       for ColCounter := 1 to Cols do
        begin
         Table.Cells[RowCounter,ColCounter-1].SetItemText(0,GetPiece(Fields[RowCounter],#9,ColCounter,ColCounter));
The header row is always centered and bold and than the data rows are
dynamicully provided as a tab separated string like Left#9Right#9Right#9Left

Posted: Sat Sep 11, 2010 6:47 pm
by Sergey Tkachenko
You cannot include #9 in the item text.
Instead of

Code: Select all

Cell.SetItemText(0, s)
use

Code: Select all

Cell.Clear;
Cell.AddTextNL(s, 0, 0, 0);

Posted: Sun Sep 12, 2010 10:35 am
by jclaes
The text is not the problem it is the alignment of the cells that's is the problem. I want to parse a stringlist that has the alignment of each cell as text in it.

Item[0] := Center#9Center#9Center#9Center
Item[1] := Left#9Right#9Left#9Center

Each new item of the ItemList is the row of the table and each part of the #9 seperated string is the alignment.

So the second row of the table the 1st cell is left aligned the 2nd right aligned the 3rd left and the 4rd centered

Is their an easy why to align a cell ? For example table.cells[row,col].aligment = leftjustify ..

Posted: Sun Sep 12, 2010 11:30 am
by Sergey Tkachenko
Horizontal text alignment is a property of paragraph, not a cell.
You can place left-, right- and centered paragraphs in RVStyle.
To assign paragraph index to item, use:
Table.Cells[RowCounter,ColCounter-1].GetItem(0).ParaNo := ...