Type | Description | |||
Item as Variant | A long expression that indicates the item's handle | |||
ColIndex as Variant | A long expression that indicates the column's index or the cell's handle, a string expression that indicates the column's caption or key. | |||
Editor | An Editor object being created or accessed |
The CellEditor property gets you the custom cell editor if it exists, else it creates it. The CellEditor property creates an empty editor if it wasn't created before, so please pay attention when creating custom cell editors on the fly. You can use the HasCellEditor property to check whether a cell has associated a custom editor ( created using the CellEditor property ). You can have different type of editors in the same column using the CellEditor property. The CellEditor property builds a new editor for a specific cell. By default, the cell's editor is the default column's editor. Use the EditType property to specify an editor for the column. Use the DeleteCellEditor method to clear a particular cell editor created using the CellEditor property. Use the CellEditorVisible property to hide the cell's editor. You can use the BeginUpdate, EndUpdate method to refresh the control.
The following VB sample assigns a date type editor to the first cell:
With Grid1.Items Dim h As EXGRIDLibCtl.HITEM h = .ItemByIndex(0) If Not .HasCellEditor(h, 0) Then With .CellEditor(h, 0) .EditType = DateType End With End If End With
The following VB sample assigns a spin type editor with min and max values:
With Grid1.Items With .CellEditor(.FirstVisibleItem, 0) .EditType = SliderType .Option(exSliderWidth) = 0 .Option(exSliderMin) = 5 .Option(exSliderMax) = 10 End With End With
The following C++ sample assigns a date type editor to the first cell:
#include "Items.h" #include "Editor.h" void OnButton1() { CItems items = m_grid.GetItems(); COleVariant vtItem( items.GetItemByIndex( 0 ) ), vtColumn( (long)0 ); if ( !items.GetHasCellEditor( vtItem, vtColumn ) ) { CEditor editor = items.GetCellEditor( vtItem, vtColumn ); editor.SetEditType( 7 /*DateType*/ ); } }
The following C++ sample assigns a spin type editor with min and max values:
#include "Items.h" #include "Editor.h" CItems items = m_grid.GetItems(); CEditor editor = items.GetCellEditor( COleVariant( items.GetFirstVisibleItem() ), COleVariant( long(0) ) ); editor.SetEditType( 20 /*SliderType*/ ); editor.SetOption( 41 /*exSliderWidth */, COleVariant( long(0) ) ); editor.SetOption( 43 /*exSliderMin*/, COleVariant( long(5) ) ); editor.SetOption( 44 /*exSliderMax*/, COleVariant( long(10) ) );
The following VB.NET sample assigns a date type editor to the first cell:
With AxGrid1.Items Dim h As Integer = .ItemByIndex(0) If Not .HasCellEditor(h, 0) Then With .CellEditor(h, 0) .EditType = EXGRIDLib.EditTypeEnum.DateType End With End If End With
The following VB.NET sample assigns a spin type editor with min and max values:
With AxGrid1.Items With .CellEditor(.FirstVisibleItem, 0) .EditType = EXGRIDLib.EditTypeEnum.SliderType .Option(EXGRIDLib.EditorOptionEnum.exSliderWidth) = 0 .Option(EXGRIDLib.EditorOptionEnum.exSliderMin) = 5 .Option(EXGRIDLib.EditorOptionEnum.exSliderMax) = 10 End With End With
The following C# sample assigns a date type editor to the first cell:
int h = axGrid1.Items[0]; if ( !axGrid1.Items.get_HasCellEditor( h, 0 ) ) { EXGRIDLib.Editor editor = axGrid1.Items.get_CellEditor( h, 0 ); if ( editor != null ) editor.EditType = EXGRIDLib.EditTypeEnum.DateType; }
The following C# sample assigns a spin type editor with min and max values:
EXGRIDLib.Editor editor = axGrid1.Items.get_CellEditor(axGrid1.Items.FirstVisibleItem, 0); editor.EditType = EXGRIDLib.EditTypeEnum.SliderType; editor.set_Option(EXGRIDLib.EditorOptionEnum.exSliderWidth, 0); editor.set_Option(EXGRIDLib.EditorOptionEnum.exSliderMin, 5); editor.set_Option(EXGRIDLib.EditorOptionEnum.exSliderMax, 10);
The following VFP sample assigns a date type editor to the first cell:
with thisform.Grid1.Items thisform.Grid1.BeginUpdate() .DefaultItem = .ItemByIndex( 0 ) if ( !.HasCellEditor( 0, 0 ) ) .CellEditor( 0, 0 ).EditType = 7 endif thisform.Grid1.EndUpdate() endwith
The following VFP sample assigns a spin type editor with min and max values:
with thisform.Grid1.Items with .CellEditor(.FirstVisibleItem, 0) .EditType = 20 && SliderType .Option(41) = 0 && exSliderWidth .Option(43) = 5 && exSliderMin .Option(44) = 10 && exSliderMax endwith endwith