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

3 posts, 1 answers
  1. Neven
    Neven avatar
    10 posts
    Member since:
    Jul 2013

    Posted 17 Feb 2016 Link to this post

    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. Answer
    Mihail avatar
    223 posts

    Posted 19 Feb 2016 Link to this post

    Hello Neven,

    Using directly the System.Drawing.Font 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 on 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"));
    table.StyleId = style.Id;

    I hope this information is helpful for you.

    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
  3. Neven
    Neven avatar
    10 posts
    Member since:
    Jul 2013

    Posted 19 Feb 2016 Link to this post

    THANKS GUYS .. You are the most efficient supports that I have chance to deal ..
Back to Top