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

RadDocument Table Cell Borders

4 Answers 369 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 17 Sep 2012, 03:47 PM
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

4 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 20 Sep 2012, 01:24 PM
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.

0
Robert
Top achievements
Rank 1
answered on 20 Sep 2012, 02:08 PM
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
0
Accepted
Petya
Telerik team
answered on 21 Sep 2012, 08:22 AM
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.

0
Robert
Top achievements
Rank 1
answered on 21 Sep 2012, 03:39 PM
Thanks Petya,

It works perfectly.
Tags
RichTextBox
Asked by
Robert
Top achievements
Rank 1
Answers by
Petya
Telerik team
Robert
Top achievements
Rank 1
Share this question
or