Home > Blockchain >  Flow Document Table c# WPF column span to take the space of next column if available
Flow Document Table c# WPF column span to take the space of next column if available

Time:09-06

I am creating an invoice in Flow Document, I am stuck with the columns span I created a table with 3 columns, 2 to display display the description (with column span 2) and 1 to display the price now I am stuck, when I have a long description, its going to the next line instead of taking the available space for column 3

Example what i have:

Col1       Col2      Col3
1x Burger with       2.00
pizza

what i want:

Col1       Col2      Col3
1x Burger with pizza 2.00

how to handle this in flow document

my code:

headerTable.RowGroups[0].Rows.Add(new TableRow());
headerRow = headerTable.RowGroups[0].Rows[count];
headerRow.Cells.Add(new TableCell(new Paragraph(new Run("1x Burger with Pizza")) { TextAlignment = TextAlignment.Left, FontSize = printsize, FontWeight = semi })
 {
 ColumnSpan = 2
});
headerRow.Cells.Add(new TableCell(new Paragraph(new Run("2.00")) { TextAlignment = TextAlignment.Right, FontSize = printsize, FontWeight = semi }));

can someone help me with this?

CodePudding user response:

you could try this enter image description here

CodePudding user response:

@Yasar Khalid. You can try the code below.

 <FlowDocumentScrollViewer>
        <FlowDocument>
            <Table>
                <Table.Columns>
                    <TableColumn Background="LightBlue" Width="*"/>
                    <TableColumn Background="Coral" Width="*"/>
                    <TableColumn Background="Red" Width="*"/>
                </Table.Columns>
                
                <TableRowGroup>
                    <TableRow>
                        <TableCell>
                            <Paragraph>Col1</Paragraph>
                        </TableCell>
                        <TableCell>
                            <Paragraph>Col2</Paragraph>
                        </TableCell>
                        <TableCell>
                            <Paragraph>Col3</Paragraph>
                        </TableCell>
                    </TableRow>
                    <TableRow>
                        <TableCell ColumnSpan="2">
                            <Paragraph>1x Burger with pizza</Paragraph>
                        </TableCell>
                        <TableCell>
                            <Paragraph>2.00</Paragraph>
                        </TableCell>
                    </TableRow>
                    
                </TableRowGroup>
            </Table>
        </FlowDocument>
    </FlowDocumentScrollViewer>

enter image description here

  • Related