Table cell align text right

General TRichView support forum. Please post your questions here
Post Reply
Floor
Posts: 3
Joined: Sat Dec 22, 2007 2:00 pm

Table cell align text right

Post by Floor »

Hi,

I am trying to align the text in 1 colum in my table to the right ( the last column in a row of 3 colums )

All I have found so far is the TFontInfo::VAlign property and unfortunately no such thing as a TFontInfo::HAlign property :).

the table cell also only has a VAlign property TRVTableCellData::VAlign. I know you can create a right aligned Paragraph but how do you set such a style to a table cell?

[code]
styles_m->TextStyles->Add();
int leftstylenum = styles_m->TextStyles->Count-1;
styles_m->TextStyles->Items[leftstylenum]->Assign(LeftInfo);
styles_m->TextStyles->Items[leftstylenum]->Standard = false;
delete LeftInfo;

TFontInfo * RightInfo = new TFontInfo(NULL);
RightInfo->Color=(TColor)0;
RightInfo->FontName="Verdana";
RightInfo->Size=10;

styles_m->TextStyles->Add();
int rightstylenum = styles_m->TextStyles->Count-1;
styles_m->TextStyles->Items[rightstylenum]->Assign(RightInfo);
styles_m->TextStyles->Items[rightstylenum]->Standard = false;
delete RightInfo;

testtabledata_m = new TRVTableItemInfo(1,3,RichView1->RVData);
testtabledata_m->BorderWidth = 0;
testtabledata_m->CellBorderWidth = 0;
testtabledata_m->CellPadding = 2;
testtabledata_m->CellVSpacing = 0;
testtabledata_m->CellHSpacing = 0;
testtabledata_m->BorderVSpacing = 0;
testtabledata_m->BorderHSpacing = 0;
testtabledata_m->Cells[0][0]->BestWidth = 60;
testtabledata_m->Cells[0][1]->BestWidth = 100;


testtabledata_m->Cells[0][0]->Clear();
testtabledata_m->Cells[0][0]->AddNL("col1",leftstylenum,0);
testtabledata_m->Cells[0][1]->Clear();
testtabledata_m->Cells[0][1]->AddNL("col2:",leftstylenum,0);
testtabledata_m->Cells[0][2]->Clear();
testtabledata_m->Cells[0][2]->AddNL("align right !!",rightstylenum,0);

RichView1->AddItem("testtable ",testtabledata_m);
[/code]
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I know you can create a right aligned Paragraph but how do you set such a style to a table cell?
Simply use right-aligned paragraphs inside table cells.
Floor
Posts: 3
Joined: Sat Dec 22, 2007 2:00 pm

Post by Floor »

I already searched the Help and the demo applications for a possibilty to set the paragraph style of the cell but the only method I found was GetItemPara() in the help file and this function only returns the current paragraph style id.

I cannot find a method or a piece of example code to set the paragraph style to a cell :cry:
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you need to generate document with right-aligned cell? If yes, create a right-aligned paragraph style before generation, and pass its index in AddNL().
Floor
Posts: 3
Joined: Sat Dec 22, 2007 2:00 pm

Post by Floor »

Thanks Sergey, I got it working now.

I completely overlooked the last param in the AddNL() function.
Post Reply