Reputation: 43
I have a TcxGridBandedTableView called cxOptimumView. I am trying to add dynamical. I have created the column as below
AColumn := cxOptimumView.CreateColumn;
AColumn.Caption := 'Combo';
AColumn.PropertiesClass := TcxComboBoxProperties;
TcxComboBoxProperties(AColumn.Properties).Items.Add('Item1');
TcxComboBoxProperties(AColumn.Properties).Items.Add('Item2');
TcxComboBoxProperties(AColumn.Properties).Items.Add('Item3');
add a column to it? I am trying to do this in delphi. How do I do this?
Upvotes: 2
Views: 797
Reputation: 8043
You need to place the new column inside a band.
The following code creates a new band, creates a new column and then places the column into the band (You can use an existing band instead of creating a new one):
var
AColumn : TcxGridBandedColumn;
ABand : TcxGridBand;
begin
cxOptimumView.BeginUpdate();
try
//adding band
ABand := cxOptimumView.Bands.Add;
//adding column
AColumn := cxOptimumView.CreateColumn;
AColumn.Caption := 'Combo';
AColumn.PropertiesClass := TcxComboBoxProperties;
TcxComboBoxProperties(AColumn.Properties).Items.Add('Item1');
TcxComboBoxProperties(AColumn.Properties).Items.Add('Item2');
TcxComboBoxProperties(AColumn.Properties).Items.Add('Item3');
//adding column to the band
AColumn.Position.BandIndex := ABand.Index;
finally
cxOptimumView.EndUpdate();
end;
Upvotes: 2