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

Can't set Borders in Tables and Cells

7 Answers 287 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Manfred
Top achievements
Rank 2
Manfred asked on 16 Feb 2011, 01:36 PM
Hi,

got this if I try to change Borders in code behind:
Table Kopf = new Table();
TableBorders tb = new TableBorders();
tb.All.Style = BorderStyle.None;
Telerik.Windows.Documents.Model.Border.Style is readonly.

So how can I set the Borders in code behind.
Its really boring to search for this property to set for hours and hours :(

Kind Regards
Manfred

7 Answers, 1 is accepted

Sort by
0
Alex
Telerik team
answered on 16 Feb 2011, 02:27 PM
Hi Manfred,

The Border class is immutable - it cannot be modified after it is initialized. If you want to set all table borders to None, you should set the the TableBorders.All property to an new instance of the Border class. Here is an example:

Table table = new Table();
table.Borders.All = new Documents.Model.Border(BorderStyle.None);

I hope this helps.

Kind regards,
Alex
the Telerik team
0
Stergios
Top achievements
Rank 1
answered on 18 Nov 2012, 09:27 PM
I've tried to use this approach to set the table borders, but the compiler "complains" that the table.Borders.All property is ReadOnly.
Finally, how I can set properties for the table borders?

Regards
0
Manfred
Top achievements
Rank 2
answered on 19 Nov 2012, 07:23 AM
Hi Stergios,

how did you do that?
Remember, you can only set that the way Alex described:

wrong:
Table Kopf = new Table();
TableBorders tb = new TableBorders();
tb.All.Style = BorderStyle.None;

Right:
Table table = new Table();
table.Borders.All = new Documents.Model.Border(BorderStyle.None);


Best Regards
Manfred




0
Stergios
Top achievements
Rank 1
answered on 19 Nov 2012, 05:08 PM
Hello Manfred,

Please see the attached picture. What am I missing here?

Regards,

Stergios
0
Iva Toteva
Telerik team
answered on 20 Nov 2012, 12:25 PM
Hello Stergios,

The setter of the All properties of the border has been removed in the latest versions. The correct way of setting the borders of a table is either by creating a new Telerik.Windows.Documents.Model.Border instance and setting it to the table:

private void addTableWithBorders_Click_1(object sender, RoutedEventArgs e)
{
    RadDocument document = new RadDocument();
    Section section = new Section();
    document.Sections.Add(section);
    section.Blocks.Add(new Paragraph());
    Table table = new Table(2, 3);

    table.Borders = new TableBorders(new Border(BorderStyle.Single));

    section.Blocks.Add(table);
    this.editor.Document = document;
}

or using styles:
table.StyleName = RadDocumentDefaultStyles.DefaultTableGridStyleName;

I hope this helps.

Kind regards,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Stergios
Top achievements
Rank 1
answered on 20 Nov 2012, 01:19 PM
Thank you very much.

I prefer to use the styles approach.

Where can I find examples of how to create and manage styles in a RadDocument?

Regards,

Stergios
0
Iva Toteva
Telerik team
answered on 20 Nov 2012, 01:23 PM
Hello Stergios,

You can find information about styles in this article.

When it comes to the names of the default styles, they are exposed as properties of RadDocumentDefaultStyles as can be seen in the previous post, which sets the StyleName of the table.

All the best,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Manfred
Top achievements
Rank 2
Answers by
Alex
Telerik team
Stergios
Top achievements
Rank 1
Manfred
Top achievements
Rank 2
Iva Toteva
Telerik team
Share this question
or