How to set the alignment of TRVTableItemInfo in cell
How to set the alignment of TRVTableItemInfo in cell
I insert a TRVTableItemInfo into a table cell,How to set its alignment? I want to set it on the right side of the cell.
Thanks a lot!
Thanks a lot!
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: How to set the alignment of TRVTableItemInfo in cell
In TRichView, cells do not have horizontal alignment properties.
Align all paragraphs in the cell to the right.
Align all paragraphs in the cell to the right.
Re: How to set the alignment of TRVTableItemInfo in cell
How? The cell is empty before I insert a TRVTableItemInfo.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: How to set the alignment of TRVTableItemInfo in cell
The cell is not really empty, it contains one empty text item.
This code inserts a table having all cells right-alignment:
This code inserts a table having all cells right-alignment:
Code: Select all
function GetParaStyleWithAlignment(Alignment: TRVAlignment; Style: TRVStyle): Integer;
var
ParaStyle: TParaInfo;
begin
ParaStyle := TParaInfo.Create(nil);
ParaStyle.Alignment := Alignment;
Result := Style.FindParaStyle(ParaStyle);
ParaStyle.Free;
end;
...
var
Table: TRVTableItemInfo;
r, c, ParaNo: Integer;
begin
ParaNo := GetParaStyleWithAlignment(rvaRight, RichViewEdit1.Style);
Table := TRVTableItemInfo.CreateEx(5, 5, RichViewEdit1.RVData);
for r := 0 to Table.RowCount - 1 do
for c := 0 to Table.ColCount - 1 do
if Table.Cells[r, c] <> nil then
begin
Table.Cells[r, c].Clear;
Table.Cells[r, c].AddNL('', 0, ParaNo);
end;
RichViewEdit1.InsertItem('', Table);
end;
Re: How to set the alignment of TRVTableItemInfo in cell
The code does not work below. What have I missed?
table.Cells[0,0].Clear;
table.Cells[0,0].AddNL('',0,2);
richView1.AddItem('mytest1', table);
tb:=TRVTableItemInfo.CreateEx(2,2,table.Cells[0,0]);
tb.BestWidth:=60;
tb.BorderColor:=clBlack;
tb.BorderWidth:=1;
table.Cells[0,0].AddItem('mytest2',tb);
RichView1.Format;
table.Cells[0,0].Clear;
table.Cells[0,0].AddNL('',0,2);
richView1.AddItem('mytest1', table);
tb:=TRVTableItemInfo.CreateEx(2,2,table.Cells[0,0]);
tb.BestWidth:=60;
tb.BorderColor:=clBlack;
tb.BorderWidth:=1;
table.Cells[0,0].AddItem('mytest2',tb);
RichView1.Format;
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: How to set the alignment of TRVTableItemInfo in cell
What does not work exactly?
Re: How to set the alignment of TRVTableItemInfo in cell
I want tb align the cell's right side
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: How to set the alignment of TRVTableItemInfo in cell
You call AddNL with ParaNo = 2.
I do not know the value of RichView1.Style.ParaStyles[2].Alignment. If it is rvaRight, tb must be right-alignment.
To make sure that you use right alignment, use the functions from my code sample.
Instead of
call
I do not know the value of RichView1.Style.ParaStyles[2].Alignment. If it is rvaRight, tb must be right-alignment.
To make sure that you use right alignment, use the functions from my code sample.
Instead of
Code: Select all
table.Cells[0,0].AddNL('',0,2);
Code: Select all
table.Cells[0,0].AddNL('',0,GetParaStyleWithAlignment(rvaRight, RichView1.Style));
Re: How to set the alignment of TRVTableItemInfo in cell
It does not wort yet!
Code: Select all
table := TRVTableItemInfo.CreateEx(3, 2, richView1.RVData);
with table do
begin
BorderWidth := 1;
CellBorderWidth := 1;
end;
table.Cells[0, 0].BestWidth := -80;
table.Cells[0, 1].BestWidth := -20;
table.Cells[0, 0].BestHeight := 38;
table.Cells[0, 0].VAlign := TRVCellVAlign.rvcMiddle;
table.Cells[0, 1].VAlign := TRVCellVAlign.rvcMiddle;
table.Cells[1, 0].BestHeight := 38;
table.Cells[2, 0].BestHeight := 38;
table.Cells[0,0].Clear;
table.Cells[0,0].AddNL('',0,GetParaStyleWithAlignment(rvaRight,richView1.Style));
richView1.AddItem('mytest1', table);
tb:=TRVTableItemInfo.CreateEx(2,2,table.Cells[0,0]);
tb.BestWidth:=60;
tb.BorderColor:=clBlack;
tb.BorderWidth:=1;
table.Cells[0,0].AddItem('mytest2',tb);
richView1.Format;
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: How to set the alignment of TRVTableItemInfo in cell
Before calling
call
Code: Select all
table.Cells[0,0].AddItem('mytest2',tb);
Code: Select all
tb.ParaNo := GetParaStyleWithAlignment(rvaRight,richView1.Style);