how to set margins of table cell?

Hi,

how can I set the margins of a table cell? (See screenshot)

Regards,
Adi



margins_613db043.zip

1 Reply

VS Vijayakumar S Syncfusion Team March 15, 2010 07:11 PM UTC

Hi Adi,

Thank you for using Syncfusion products.

Please do find the code snippet to set the cell margin for a table/table cell.

WordDocument wordDoc = new WordDocument();
wordDoc.EnsureMinimal();
IWTable table = wordDoc.LastSection.AddTable();
RowFormat format = new RowFormat();

//This line sets cell margin for all the cells as 4f (for left, right, top and bottom margins)
format.Paddings.All = 4f;

table.ResetCells(2, 2, format, 200);


for (int rowIndex = 0; rowIndex < 2; rowIndex++)
{
for (int colIndex = 0; colIndex < 2; colIndex++)
{
WTableCell cell = table.Rows[rowIndex].Cells[colIndex];
//This line Defines whether to use same paddings as table has.
cell.CellFormat.SamePaddingsAsTable = false;

cell.CellFormat.Paddings.Left = 5.4f; //in terms of points
cell.CellFormat.Paddings.Right = 5.4f;//in terms of points
cell.CellFormat.Paddings.Top = 0;//in terms of points
cell.CellFormat.Paddings.Bottom = 0;//in terms of points
}
}

Please let us know if you have any questions.

Regards,
Vijay

Loader.
Up arrow icon