RadDocument Table Cell Borders

5 posts, 1 answers
  1. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 17 Sep 2012 Link to this post

    Hi,

    Am I setting the top table cell border correctly?
    //Discount Total Cell
    Span spanDiscountTotal = new Span(disountTotal.ToString("C", CultureInfo.CreateSpecificCulture("en-GB")));
    spanDiscountTotal.StyleName = "styleTableTotal";
    Paragraph paragraphDiscountTotal = new Paragraph();
    paragraphDiscountTotal.Inlines.Add(spanDiscountTotal);
    TableCell cellDiscountTotal = new TableCell();
    cellDiscountTotal.Borders.SetTop(new Border(5 ,BorderStyle.Single, Colors.Green));
    cellDiscountTotal.Blocks.Add(paragraphDiscountTotal);

    Notice the line of code:

    cellDiscountTotal.Borders.SetTop(new Border(5 ,BorderStyle.Single, Colors.Green));

    For some reason the top border to the cell in question is not displaying a green single line.

    I'm using library version 2012.2.912.40.

    On another slightly different topic, before I upgraded from one of the previous WPF library versions all of the borders in my table were showing. Now that I've update the libraries no table borders are visible.

    Any adivce would be greatly appreciated.

    Thanks for your time,

    Rob

  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 20 Sep 2012 Link to this post

    Hi Rob,
    Thank you for contacting us!
    You are right, that the way SetBorder() methods work is not very intuitive. They return a new instance of TableCellBorders - this is why the proper way to use them is as follows:
    cellDiscountTotal.Borders = new TableCellBorders.SetTop(new Border(5 ,BorderStyle.Single, Colors.Green));

    We will make sure to properly document this behavior.

     
    Greetings,
    Petya
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 20 Sep 2012 Link to this post

    Hi Petya,

    Thanks for getting back to me. Unfortunately the solution you have provided doesn't appear to work.

    I get the following error in VS 2010:
    Error 1 'Telerik.Windows.Documents.Model.TableCellBorders.SetTop(Telerik.Windows.Documents.Model.Border)' is a 'method' but is used like a 'type'.


    This works for setting a border to all sides of the cell:
    cellDiscountTotal.Borders = new TableCellBorders(new Border(5, BorderStyle.Single, Colors.Green));


    I can't see how to limit it only to the Top border line.

    Thanks for your time,

    Rob
  5. Answer
    Petya
    Admin
    Petya avatar
    975 posts

    Posted 21 Sep 2012 Link to this post

    Hi Rob,
    Please, excuse me. I have made a mistake in the snippet I pasted. Here is the correct code:
    cellDiscountTotal.Borders = new TableCellBorders().SetTop(new Border(5, BorderStyle.Single, Colors.Green));

    Like I said, the SetTop, SetBottom, SetLeftSetRight, SetInsideHorizontal, SetInsideVertical methods internally return a new TableCellBorders instance with the respective border changed and all the others preserved. The TableCellBorders class does not a contain a constructor which can set only one of the cell's border. The method you've found does, indeed, change all the borders.

    I apologize again for the confusion. Please try the correct snippet.

     
    Greetings,
    Petya
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  6. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 21 Sep 2012 Link to this post

    Thanks Petya,

    It works perfectly.
Back to Top
UI for WPF is Visual Studio 2017 Ready