VSFlexGrid Introduction > Merging Cells |
The VSFlexGrid control allows you to merge cells, making them span multiple rows or columns. This capability can be used to enhance the appearance and clarity of the data displayed on the grid. The effect of these settings is similar to the HTML "<ROWSPAN>" and "<COLSPAN>" tags.
Cell merging is controlled by three properties: MergeCells, MergeRow(), and MergeCol(). MergeCells enables cell merging for the entire grid. After it is set to a non-zero value, rows that have MergeRow() set to True will be allowed to merge across and columns that have MergeCol() set to True will be allowed to merge down. The merging will occur if adjacent cells contain the same non-empty string. The MergeCells property has several settings that allow you to restrict cell merging in different ways. For details on how to use it, see the MergeCells property in the control reference section.
Note that there is no method to force a pair of cells to merge. The merging is done automatically based on the cell contents. This makes it easy to provide merged views of sorted data, where values in adjacent rows present repeated data.
Cell merging has several possible uses. For example, you can use it to create merged table headers, merged data views, or grids where the text spills into adjacent columns.