Skip to main content

Using provider mode: Creating columns

  • 2 minutes to read
  1. Base class structure

  2. TPriceList

  3. TUserDataSource

  4. Creating columns

  5. Full code

4. Creating columns

The GenerateColumns method creates columns in a grid control, and this presents data from the TPriceList object. It also assigns every column a unique value via the TcxGridColumn.DataBinding.Data property used to identify it in the GetValue and GetInfoForCompare methods.

GenerateColumns sets the type for values in columns via the TcxGridColumn.DataBinding. ValueTypeClass property.

procedure GenerateColumns(AGridTableView: TcxGridTableView);
begin
  with AGridTableView do
  begin
    OptionsSelection.HideFocusRect := False;
    OptionsSelection.MultiSelect := True;
    ClearItems;
    with CreateColumn as TcxGridColumn do
    begin
      Caption := 'Description';
      DataBinding.ValueTypeClass := TcxStringValueType;
      DataBinding.Data := Pointer(DescriptionID);
      Width := 100;
    end;
    with CreateColumn as TcxGridColumn do
    begin
      Caption := 'OnHand';
      DataBinding.ValueTypeClass := TcxIntegerValueType;
      DataBinding.Data := Pointer(OnHandID);
      Width := 100;
    end;
    with CreateColumn as TcxGridColumn do
    begin
      Caption := 'Price';
      DataBinding.ValueTypeClass := TcxCurrencyValueType;
      DataBinding.Data := Pointer(PriceID);
      Width := 100;
    end;
  end;
end;

The next section includes the complete code used in this example.

See Also