The simplest way to set the style of a table cell
Posted: Sun Sep 21, 2014 10:03 am
I've my grid class, that works fine and use its own styles. I want to insert that grid in a TRichViewEdit component. All's ok for cell text and borders but i can't set font styles (name, size...) and text alignment.
I convert my styles to TFontInfo and add it to TRVStyle:
The problem seems to be in GetTable()->AssociatedTextStyleNo that seems to do nothing or maybe i've not undesrtood how styles works, in TRichViewEdit?
[/quote]
I convert my styles to TFontInfo and add it to TRVStyle:
Code: Select all
int AddStyle(TRVStyle *rvs, TFontInfo *pFontInfo)
{
rvs->TextStyles->Add();
int NewStyleNo = rvs->TextStyles->Count - 1;
rvs->TextStyles->Items[NewStyleNo]->Assign(pFontInfo);
rvs->TextStyles->Items[NewStyleNo]->Standard = false;
return NewStyleNo;
}
[/quote]
In my style objects, i store the returned NewStyleNo into an UserData integer, to use it when i later add cells from my grid to TRichView:
[code]
if(TRVTableCellData *pCell = pTable->Cells[r][c])
{
clsString sText = "some text";
if(TLigsStyle *pStyle = ligsprinter->GetStyleP(sStyle))
{
pCell->GetTable()->AssociatedTextStyleNo = pStyle->UserData;
}
pCell->SetItemText(0, CS(sText));
}
[/quote]