Search code examples
delphidelphi-xe2tcxgrid

Setting TcxSpinEdit property to column when building TcxGrid at runtime


I'm working on someone else's code where they're building a TcxGrid without going through the visual editor. I will be exporting that grid to excel so I need to set the column type to TcxSpinEdit (contents are all numbers).

How can I set the property? I tried with PropertyClass and PropertyClassName but none of them work (I still get the "number as text" warning in excel).

This is the relevant part:

var
Stolpec: TcxGridDBColumn;

[...]

if CheckBoxStevilkoMultiTime.Checked    then
    begin
      Stolpec := cxGrid1DBTableView3.CreateColumn;
      Stolpec.DataBinding.FieldName := 'STVLK_INI_C';
      Stolpec.Width := larghCol;
      Stolpec.FooterAlignmentHorz := taRightJustify;
      Stolpec.GroupSummaryAlignment := taRightJustify;
      Stolpec.Name := 'cxGrid1DBTableView3' + Colonna.DataBinding.FieldName;
      TcxGridDBTableSummaryItem(cxGrid1DBTableView3.DataController.Summary.DefaultGroupSummaryItems[5]).Column := Stolpec;
      TcxGridDBTableSummaryItem(cxGrid1DBTableView3.DataController.Summary.DefaultGroupSummaryItems[5]).Position := posIndx;
      Stolpec.Caption := 'Stevilko';
      Stolpec.Options.Editing := False;
    end;

Solution

  • uses
       cxSpinEdit;
    
    ...
      Stolpec.PropertiesClass := TcxSpinEditProperties;
      TcxSpinEditProperties(Stolpec.Properties).MaxValue:= 10;
    ...