align a table created from a tab separated stringlist

General TRichView support forum. Please post your questions here
Post Reply
jclaes
Posts: 6
Joined: Fri Jan 23, 2009 10:49 am

align a table created from a tab separated stringlist

Post 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
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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);
jclaes
Posts: 6
Joined: Fri Jan 23, 2009 10:49 am

Post 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 ..
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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 := ...
Post Reply