Type | Description | |||
Cell1 as Variant | A long expression that indicates the handle of the cell being merged, or a safe array that holds a collection of handles for the cells being merged. Use the ItemCell property to retrieves the handle of the cell. The first cell (in the list, if exists) specifies the cell being displayed in the new larger cell. | |||
Cell2 as Variant | A long expression that indicates the handle of the cell being merged, or a safe array that holds a collection of handles for the cells being merged. Use the ItemCell property to retrieves the handle of the cell. The first cell in the list specifies the cell being displayed in the new larger cell. | |||
Options as Variant | Reserved. |
The following samples adds three columns, a root item and two child items:
With Tree1 .BeginUpdate .MarkSearchColumn = False .DrawGridLines = exAllLines .LinesAtRoot = exLinesAtRoot With .Columns.Add("Column 1") .Def(exCellCaptionFormat) = exHTML End With .Columns.Add "Column 2" .Columns.Add "Column 3" With .Items Dim h As Long h = .AddItem("Root. This is the root item") .InsertItem h, , Array("Child 1", "SubItem 2", "SubItem 3") .InsertItem h, , Array("Child 2", "SubItem 2", "SubItem 3") .ExpandItem(h) = True .SelectItem(h) = True End With .EndUpdate End With
and it looks like follows ( notice that the caption of the root item is truncated by the column that belongs to ):
If we are merging the first three cells in the root item we get:
You can merge the first three cells in the root item using any of the following methods:
With ComboBox1 With .Items .CellMerge(.RootItem(0), 0) = Array(1, 2) End With End With
With ComboBox1 .BeginUpdate With .Items Dim r As Long r = .RootItem(0) .CellMerge(r, 0) = 1 .CellMerge(r, 0) = 2 End With .EndUpdate End With
With ComboBox1 .BeginUpdate With .Items Dim r As Long r = .RootItem(0) .MergeCells .ItemCell(r, 0), .ItemCell(r, 1) .MergeCells .ItemCell(r, 0), .ItemCell(r, 2) End With .EndUpdate End With
With ComboBox1 With .Items Dim r As Long r = .RootItem(0) .MergeCells .ItemCell(r, 0), Array(.ItemCell(r, 1), .ItemCell(r, 2)) End With End With
With ComboBox1 With .Items Dim r As Long r = .RootItem(0) .MergeCells Array(.ItemCell(r, 0), .ItemCell(r, 1), .ItemCell(r, 2)) End With End With
The following VB sample merges the first three cells:
With ComboBox1.Items .MergeCells .ItemCell(.FocusItem, 0), Array(.ItemCell(.FocusItem, 1), .ItemCell(.FocusItem, 2)) End With
The following C++ sample merges the first three cells:
#include "Items.h" CItems items = m_combobox.GetItems(); COleVariant vtFocusCell( items.GetItemCell(items.GetFocusItem(), COleVariant( (long)0 ) ) ), vtMissing; V_VT( &vtMissing ) = VT_ERROR; items.MergeCells( vtFocusCell, COleVariant( items.GetItemCell(items.GetFocusItem(), COleVariant( (long)1 ) ) ), vtMissing ); items.MergeCells( vtFocusCell, COleVariant( items.GetItemCell(items.GetFocusItem(), COleVariant( (long)2 ) ) ), vtMissing );
The following VB.NET sample merges the first three cells:
With AxComboBox1.Items .MergeCells(.ItemCell(.FocusItem, 0), .ItemCell(.FocusItem, 1)) .MergeCells(.ItemCell(.FocusItem, 0), .ItemCell(.FocusItem, 2)) End With
The following C# sample merges the first three cells:
EXCOMBOBOXLib.Items items = axComboBox1.Items; items.MergeCells(items.get_ItemCell( items.FocusItem, 0 ), items.get_ItemCell( items.FocusItem, 1 ),""); items.MergeCells(items.get_ItemCell(items.FocusItem, 0), items.get_ItemCell(items.FocusItem, 2),"");
The following VFP sample merges the first three cells:
with thisform.ComboBox1.Items .MergeCells(.ItemCell(.FocusItem,0), .ItemCell(.FocusItem,1), "") .MergeCells(.ItemCell(.FocusItem,0), .ItemCell(.FocusItem,2), "") endwith
Now, the question is what should I use in my program in order to merge some cells? For instance, if you are using handle to cells ( HCELL type ), we would recommend using the MergeCells method, else you could use as well the CellMerge property