vcl-cxgridtableview-dot-tcxgridtableview-ffa51dfe.md
Creates a new column and adds it to the Columns collection.
function CreateColumn: TcxGridColumn;
| Type | Description |
|---|---|
| TcxGridColumn |
The created column.
|
Call the CreateColumn function to create a new unbound column. The Columns property provides indexed access to all columns in the unbound Table grid View.
The following code example creates an unbound Table View column, assigns an in-place spin editor to it, and limits the editor’s input value range:
uses cxSpinEdit;
// ...
var
AColumn: TcxGridColumn;
ASpinEditProperties: TcxSpinEditProperties;
begin
AColumn := cxGrid1TableView1.CreateColumn; // Creates a new unbound column
AColumn.DataBinding.ValueType := 'Currency'; // Changes the column value type to "Currency"
AColumn.PropertiesClass := TcxSpinEditProperties; // Assigns an in-place spin editor
ASpinEditProperties := AColumn.Properties as TcxSpinEditProperties;
ASpinEditProperties.MinValue := 0; // Sets the minimum edit value
ASpinEditProperties.MaxValue := 1000; // Sets the maximum edit value
ASpinEditProperties.Circular := True; // Loops value changes within the defined range
end;
#include "cxSpinEdit.hpp"
// ...
TcxGridColumn *AColumn;
TcxSpinEditProperties *ASpinEditProperties;
// ...
AColumn = cxGrid1TableView1->CreateColumn(); // Creates a new unbound column
AColumn->DataBinding->ValueType = "Currency"; // Changes the column value type to "Currency"
AColumn->PropertiesClass = __classid(TcxSpinEditProperties); // Assigns an in-place spin editor
ASpinEditProperties = dynamic_cast<TcxSpinEditProperties*>(AColumn->Properties);
ASpinEditProperties->MinValue = 0; // Sets the minimum edit value
ASpinEditProperties->MaxValue = 1000; // Sets the maximum edit value
ASpinEditProperties->Circular = true; // Loops value changes within the defined range
To delete a grid column, release it directly in code (call the Free procedure in Delphi or use the delete keyword in C++Builder):
cxGrid1TableView1Column1.Free;
delete cxGrid1TableView1Column1;
See Also
TcxGridDBTableView.CreateColumn Function