在TcxGridDBTableView和TcxGridDBColumn中有三个事件:
GetStoredProperties
GetStoredPropertyValue
SetStoredPropertyValue
procedure TFrm_Company.cxgrdbclmn_02GetStoredProperties(
Sender: TcxCustomGridTableItem; AProperties: TStrings);
begin
inherited;//增加一个属性
AProperties.Add('HeaderAlignmentHorz');
end;
procedure TFrm_Company.cxgrdbclmn_02GetStoredPropertyValue(
Sender: TcxCustomGridTableItem; const AName: string; var AValue: Variant);
begin
inherited;//给新增加的属性赋值,这里是一个枚举类型
if (AName = 'HeaderAlignmentHorz') then
AValue := GetEnumName(TypeInfo(TAlignment),Ord(TcxCustomGridColumn(Sender).HeaderAlignmentHorz));
end;
procedure TFrm_Company.cxgrdbclmn_02SetStoredPropertyValue(
Sender: TcxCustomGridTableItem; const AName: string; const AValue: Variant);
begin
inherited;//读取属性值
if (AName = 'HeaderAlignmentHorz') then
TcxCustomGridColumn(Sender).HeaderAlignmentHorz :=
TAlignment(GetEnumValue(TypeInfo(TAlignment), AValue));
end;