property Items.CellMerge([Item as Variant], [ColIndex as Variant]) as Variant
Retrieves or sets a value that indicates the index of the cell that's merged to.

 TypeDescription 
   Item as Variant A long expression that indicates the item's handle.  
   ColIndex as Variant A long expression that indicates the column's index, a string expression that indicates the column's caption or the column's key.  
   Variant A long expression that indicates the index of the cell that's merged with, a safe array that holds the indexes of the cells being merged.  
Use the CellMerge property to combine two or more cells in the same item in a single cell. The data of the source cell is displayed in the new larger cell. All the other cells' data is not lost. Use the ItemDivider property to display a single cell in the entire item. Use the UnmergeCells method to unmerge the merged cells. Use the CellMerge property to unmerge a single cell. Use the MergeCells method to combine one or more cells in a single cell. Use the SplitCell property to split a cell. Use the Add method to add new columns to the control.

The following VB sample merges the first three cells in the focused item:

With Grid1.Items
    .CellMerge(.FocusItem, 0) = 1
    .CellMerge(.FocusItem, 0) = 2
End With

The following C++ sample merges the first three cells in the focused item:

#include "Items.h"
CItems items = m_grid.GetItems();
COleVariant vtItem( items.GetFocusItem() ), vtColumn( long( 0 ) );
items.SetCellMerge( vtItem, vtColumn, COleVariant( long(1) ) );
items.SetCellMerge( vtItem, vtColumn, COleVariant( long(2) ) );

The following VB.NET sample merges the first three cells in the focused item:

With AxGrid1.Items
    .CellMerge(.FocusItem, 0) = 1
    .CellMerge(.FocusItem, 0) = 2
End With

The following C# sample merges the first three cells in the focused item:

axGrid1.Items.set_CellMerge(axGrid1.Items.FocusItem, 0, 1);
axGrid1.Items.set_CellMerge(axGrid1.Items.FocusItem, 0, 2);

The following VFP sample merges the first three cells in the focused item:

with thisform.Grid1.Items
	.DefaultItem = .FocusItem
	.CellMerge(0,0) = 1
	.CellMerge(0,0) = 2
endwith

In other words, the sample shows how to display the first cell using the space occupied by three cells

The following sample shows few methods to unmerge cells: 

You can merge the first three cells in the root item using any of the following methods:


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.