This is a migrated thread and some comments may be shown as answers.

set TableCell [or TableRow] Font style [size, weight, font family]

2 Answers 752 Views
WordsProcessing
This is a migrated thread and some comments may be shown as answers.
Neven
Top achievements
Rank 2
Neven asked on 17 Feb 2016, 07:27 PM

I figured out this solution [code bellow] but is any other solution [probably it is] that I can use ?
Can use directly somehow System.Drawing.Font :
System.Drawing.Font fArialB  = new System.Drawing.Font("Arial", 18, System.Drawing.FontStyle.Bold);
instead to use Run object for every cell as bellow ?


        private void SetCellStyle(ref Telerik.Windows.Documents.Flow.Model.TableCell cell, string CellTxt, double CellSize)
        {
            cell.Shading.BackgroundColor = new ThemableColor(System.Windows.Media.Colors.White);
            cell.PreferredWidth = new TableWidthUnit(CellSize);
            Paragraph cellPar = cell.Blocks.AddParagraph();
            cellPar.TextAlignment = Alignment.Right;
            Run runCellTextFormat = cellPar.Inlines.AddRun(CellTxt);
            runCellTextFormat.FontSize = 18;
            runCellTextFormat.FontWeight = FontWeights.Bold;
            runCellTextFormat.FontFamily = new ThemableFontFamily(new System.Windows.Media.FontFamily("Arial"));
        }
Sorry to bother you guys with such probably simple questions, but I am in some short time frame to move stuff from Infagistic to Telerik.

2 Answers, 1 is accepted

Sort by
0
Accepted
Mihail
Telerik team
answered on 19 Feb 2016, 02:04 PM
Hello Neven,

Using directly the System.Drawing. is not possible. You should convert it to classes from System.Windows. Like System.Windows.Media.Colors, System.Windows.FontWeights etc.

Regarding the stylization of a table cell, if all of the cells should have the same styling you could use the Table style to achieve this. Here is a help article on how the styles are working: Styles. And here is an example how this could be done: 
Style style = new Style("MyTableStyle", StyleType.Table);
style.CharacterProperties.ForegroundColor.LocalValue = new ThemableColor(Colors.Red);
style.CharacterProperties.FontWeight.LocalValue = FontWeights.Bold;
style.CharacterProperties.FontFamily.LocalValue = new ThemableFontFamily(new FontFamily("Arial"));
 
document.StyleRepository.Add(style);
 
table.StyleId = style.Id;


I hope this information is helpful for you.

Regards,
Mihail
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Neven
Top achievements
Rank 2
answered on 19 Feb 2016, 02:06 PM
THANKS GUYS .. You are the most efficient supports that I have chance to deal ..
Tags
WordsProcessing
Asked by
Neven
Top achievements
Rank 2
Answers by
Mihail
Telerik team
Neven
Top achievements
Rank 2
Share this question
or