Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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