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

Change default padding on a TableCell

1 Answer 311 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 20 Jul 2020, 05:52 PM

When I create a `TableCell` in a flow document it is has a left & right padding of ~7.  How can I change the default padding?

I assume styles, right?  https://docs.telerik.com/devtools/document-processing/libraries/radwordsprocessing/concepts/styles

I tried changing the padding but it says there's only a getter: `tableStyle.TableCellProperties.Padding = new Padding(0)`

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 22 Jul 2020, 10:46 AM

Hello Mike,

You can set the TableCellPadding property of the entire table. Here is a complete example: 

private void RadButton_Click(object sender, RoutedEventArgs e)
{
    RadFlowDocument document = new RadFlowDocument();
    RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);

    Table table = editor.InsertTable(3, 3);
    table.TableCellPadding = new Telerik.Windows.Documents.Primitives.Padding(0);
    int count = 0;
    foreach (var row in table.Rows)
    {
        foreach (var cell in row.Cells)
        {
            Paragraph paragraph = cell.Blocks.AddParagraph();
            Run run1 = new Run(document);
            run1.Text = "CELL" + count++;
            paragraph.Inlines.Add(run1);
            cell.Borders = new  TableCellBorders(new Telerik.Windows.Documents.Flow.Model.Styles.Border(1, BorderStyle.Single,new Telerik.Windows.Documents.Spreadsheet.Model.ThemableColor(Colors.Red)));
        }
    }

    DocxFormatProvider provider = new DocxFormatProvider();
    var bytes = provider.Export(document);
    File.WriteAllBytes(@"..\..\result.docx", bytes);
    Process.Start(@"..\..\result.docx");
}

Let me know if you have any other questions.

Regards,
Dimitar
Progress Telerik

Tags
General Discussions
Asked by
Mike
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or