TcxGridDBDataController.CreateAllItems(Boolean) Method
Creates grid items for fields in the bound dataset.
Declaration
procedure CreateAllItems(AMissingItemsOnly: Boolean = False);
Parameters
Name | Type | Description |
---|---|---|
AMissingItemsOnly | Boolean | Optional. Specifies if the data controller creates grid items for all fields in the bound dataset. You can pass Note If you omit this parameter, the procedure always creates grid items for all fields in the bound dataset. |
Remarks
Call the CreateAllItems
procedure to create grid items for all fields in the bound dataset. The CreateAllItems
procedure assigns corresponding dataset field names to the DataBinding.FieldName property of all created grid items.
Note
If a source dataset field’s Visible property is set to False
, the corresponding created grid item’s Visible property is also set to False
.
Code Example
The following code example creates three dataset fields and two records in a TdxMemData component, and displays data in a bound data-aware grid Table View:
uses
dxmdaset, cxGrid, cxGridDBTableView;
// ...
procedure TMyForm.CreateField(AMemData: TdxMemData; AFieldName: string; AFieldType: TFieldType);
var
AFieldDef: TFieldDef;
begin
if ((AMemData = nil) or (AFieldName = '')) then Exit;
AFieldDef := AMemData.FieldDefs.AddFieldDef;
AFieldDef.Name := AFieldName;
AFieldDef.DataType := AFieldType;
AFieldDef.CreateField(AMemData);
end;
procedure TMyForm.FormCreate(Sender: TObject);
begin
dxMemData1.DisableControls;
try
if dxMemData1.Active then
dxMemData1.Close;
// Create three fields in the memory-based dataset
CreateField(dxMemData1, 'ID', ftInteger);
CreateField(dxMemData1, 'FirstName', ftString);
CreateField(dxMemData1, 'LastName', ftString);
// Create two records and populate corresponding data cells
dxMemData1.Open;
dxMemData1.Append;
dxMemData1.FieldByName('ID').AsInteger := 0;
dxMemData1.FieldByName('FirstName').AsString := 'James';
dxMemData1.FieldByName('LastName').AsString := 'Packard';
dxMemData1.Append;
dxMemData1.FieldByName('ID').AsInteger := 1;
dxMemData1.FieldByName('FirstName').AsString := 'Hannah';
dxMemData1.FieldByName('LastName').AsString := 'Brooklyn';
dxMemData1.Post;
finally
dxMemData1.EnableControls;
end;
cxGrid1DBTableView1.DataController.CreateAllItems();
end;
Grid Column Deletion
To delete a grid column, release it directly in code (call the Free procedure in Delphi or use the delete
keyword in C++Builder):