property Items.SplitCell ([Item as Variant], [ColIndex as Variant]) as Variant
Splits a cell, and returns the inner created cell.

 TypeDescription 
   Item as Variant A long expression that indicates the handle of the item where a cell is being divided, or 0. If the Item parameter is 0, the ColIndex parameter must indicate the handle of the cell.  
   ColIndex as Variant A long expression that indicates the index of the column where a cell is divided, or a long expression that indicates the handle of the cell being divided, if the Item parameter is missing or it is zero.  
   Variant A long expression that indicates the handle of the cell being created.  
The SplitCell method splits a cell in two cells. The newly created cell is called inner cell. The SplitCell method always returns the handle of the inner cell. If the cell is already divided using the SplitCell method, it returns the handle of the inner cell without creating a new inner cell. You can split an inner cell too, and so you can have a master cell divided in multiple cells. Use the CellWidth property to specify the width of the inner cell. Use the CellValue property to assign a value to a cell. Use the InnerCell property to access an inner cell giving its index. Use the CellParent property to get the parent of the inner cell. Use the CellItem property to get the owner of the cell. Use the UnsplitCell method  to remove the inner cell if it exists. Use the MergeCells property to combine two or more cells in a single cell. The SelectColumInner property indicates the index of the inner cell that has the focus ( or it is selected ). Use the SelectableItem property to specify the user can select an item. Include the exIncludeInnerCells flag in the FilterList property and so the drop down filter window lists the inner cells too.

( "Merge" means multiple cells in a single cell, "Split" means multiple cells inside a single cell )

The following VB sample splits a single cell in two cells ( Before running the following sample, please make sure that your control contains columns, and at least an item ):

With Grid1.Items
    Dim h As HITEM, f As HCELL
    h = .FirstVisibleItem
    f = .SplitCell(h, 0)
    .CellValue(, f) = "inner cell"
End With

The following VB sample splits a cell in three cells ( Before running the following sample, please make sure that your control contains columns, and at least an item ):

With Grid1.Items
    Dim h As HITEM, f As HCELL
    h = .FirstVisibleItem
    f = .SplitCell(h, 0)
    .CellValue(, f) = "inner cell 1"
    f = .SplitCell(, f)
    .CellValue(, f) = "inner cell 2"
End With

The following C++ sample splits the first visible cell in two cells:

#include "Items.h"
CItems items = m_grid.GetItems();
COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR;
COleVariant vtSplit = items.GetSplitCell( COleVariant( items.GetFirstVisibleItem() ), COleVariant( long(0) ) );
items.SetCellCaption( vtMissing, vtSplit, COleVariant( "inner cell" ) );

The following VB.NET sample splits the first visible cell in two cells:

With AxGrid1.Items
    Dim i As Object
    i = .SplitCell(.FirstVisibleItem, 0)
    .CellValue(Nothing, i) = "inner cell"
End With

The following C# sample splits the first visible cell in two cells:

EXGRIDLib.Items items = axGrid1.Items;
object i = items.get_SplitCell(items.FirstVisibleItem, 0);
items.set_CellValue(null, i, "inner cell");

The following VFP sample splits the first visible cell in two cells:

with thisform.Grid1.Items
	local i
	i = .SplitCell(.FirstVisibleItem,0)
	local s, crlf
	crlf = chr(13) + chr(10)
	s = "Items" + crlf
	s = s + "{" + crlf
	s = s + "CellValue(," + str(i) + ") = " + chr(34) + "inner cell" + chr(34) + crlf
	s = s + "}"
	thisform.Grid1.Template = s
endwith
 

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