Changing table properties in code after calling InsertTable()

0 Answers 29 Views
RichTextBox
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
Patrick asked on 17 Jun 2024, 07:36 PM
I have a button which inserts a table.


myRichTextBox.InsertTable(2,4)

I want to modify some properties on the table after it is inserted.

I want to set fontsize, fontfamily, change border and cell color to RED and make it so that the table will always fill the available width. Is this a possibility? Or do I have to manually build out the entire table and insert at cursor location?
Dimitar
Telerik team
commented on 18 Jun 2024, 06:30 AM

Hi Patrick, 

You can use the following approach to get the table and set its properties: 

radRichTextBox.InsertTable(4, 2);
var table = radRichTextBox.Document.CaretPosition.GetCurrentTable();
table.Borders = new TableBorders(new Telerik.Windows.Documents.Model.Border(BorderStyle.Single, Colors.Red));

radRichTextBox.UpdateEditorLayout();

Patrick
Top achievements
Rank 1
Iron
Iron
Iron
commented on 20 Jun 2024, 02:03 PM

This worked out great! Thanks!

No answers yet. Maybe you can help?

Tags
RichTextBox
Asked by
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or