locked
Differences between grid and table in WPF? RRS feed

  • Question

  • I want to know any differences between grid and table in WPF? Or one is include the other ,what's scenarios they best suited for?And I often deal with the situation of merge the cells to the right or down of the grid, and it seems it can be done in word, any solutions in PDF? Thank u.


    Wednesday, May 27, 2015 6:06 AM

Answers

  • Please only ask one question per thread.

    The table is a flowdocument media object rather than a UI object.

    Use Grid in windows and usercontrols.

    Use Table in a flowdocument.

    Did you not google.. at all?

    Because the difference is explained on msdn:

    https://msdn.microsoft.com/en-us/library/ms747133(v=vs.110).aspx

    "

                      

    How is Table Different then Grid?


                      
                    

    Table                   and Grid share some common functionality, but each is best suited for different scenarios. A Table is designed for use within flow content (see Flow Document Overview for more information on flow content). Grids are best used inside of forms (basically anywhere outside of flow content). Within a FlowDocument, Table supports flow content behaviors like pagination, column reflow, and content selection while a Grid does not. A Grid on the other hand is best used outside of a FlowDocument for many reasons including Grid adds elements based on a row and column index, Table does not. The Grid element allows layering of child content, allowing more than one element to exist within a single "cell." Table does not support layering. Child elements of a Grid can be absolutely positioned relative to the area of their "cell" boundaries. Table does not support this feature. Finally, a Grid requires less resources then a Table so consider using a Grid to improve performance.

    ".

    In order to span cells in a table you can do:

    <TableRow>
       <TableCell RowSpan="2">

    or

    <TableRow>
       <TableCell ColumnSpan="2">

    And you can convert flowdocuments to pdf via various means.  I would google that part. here's an example hit you will find:

    http://stackoverflow.com/questions/9182137/whats-the-best-way-to-convert-a-flowdocument-into-pdf


    Hope that helps.

    Technet articles: WPF: Change Tracking; All my Technet Articles

    • Marked as answer by Floraaa Wednesday, May 27, 2015 8:28 AM
    Wednesday, May 27, 2015 7:23 AM

All replies

  • Please only ask one question per thread.

    The table is a flowdocument media object rather than a UI object.

    Use Grid in windows and usercontrols.

    Use Table in a flowdocument.

    Did you not google.. at all?

    Because the difference is explained on msdn:

    https://msdn.microsoft.com/en-us/library/ms747133(v=vs.110).aspx

    "

                      

    How is Table Different then Grid?


                      
                    

    Table                   and Grid share some common functionality, but each is best suited for different scenarios. A Table is designed for use within flow content (see Flow Document Overview for more information on flow content). Grids are best used inside of forms (basically anywhere outside of flow content). Within a FlowDocument, Table supports flow content behaviors like pagination, column reflow, and content selection while a Grid does not. A Grid on the other hand is best used outside of a FlowDocument for many reasons including Grid adds elements based on a row and column index, Table does not. The Grid element allows layering of child content, allowing more than one element to exist within a single "cell." Table does not support layering. Child elements of a Grid can be absolutely positioned relative to the area of their "cell" boundaries. Table does not support this feature. Finally, a Grid requires less resources then a Table so consider using a Grid to improve performance.

    ".

    In order to span cells in a table you can do:

    <TableRow>
       <TableCell RowSpan="2">

    or

    <TableRow>
       <TableCell ColumnSpan="2">

    And you can convert flowdocuments to pdf via various means.  I would google that part. here's an example hit you will find:

    http://stackoverflow.com/questions/9182137/whats-the-best-way-to-convert-a-flowdocument-into-pdf


    Hope that helps.

    Technet articles: WPF: Change Tracking; All my Technet Articles

    • Marked as answer by Floraaa Wednesday, May 27, 2015 8:28 AM
    Wednesday, May 27, 2015 7:23 AM
  • Please google the differences...and as for merge cells for grid, you can try this third party PDF library.

    Refer code

    row0.Cell[0].RowSpan=2;

    row.Cell[0].ColumnSpan=3;

    Here is a demo to show how to merge cells of grid.

    How to merge cells in gird .

    Wednesday, May 27, 2015 8:56 AM