cxgrid columns中怎么没有这个valuetype属性
请教各位,我要在cxgrid中添加一列非绑定字段的checkbox,放在第一列,看到很多代码中有这句grid_view.columns[0].databinding.valuetype:='boolean' 我的cxgrid中怎么没有这个valuetype属性?
我的cxgrid是4.5.2版的,是不是版本低了?
[解决办法]
我正好借鉴整理了一下,以供参考:
<View>.DataController.DataModeController.GridMode:=False;
<View>.DataController.DataModeController.SmartRefresh:=True;
<View>.DataController.KeyFieldNames:='唯一字段的名字';//该字段只要数据不重复即可
<Col>.DataBinding.ValueTypeClass:=TcxBooleanValueType;//TcxStringValueType、TcxIntegerValueType均可,只要(<Col>.Properties as
TcxCheckBoxProperties).ValueChecked、(<Col>.Properties as TcxCheckBoxProperties).ValueUnchecked中设置为相应类型即可。
<Col>.PropertiesClass:=TcxCheckBoxProperties;
(<Col>.Properties as TcxCheckBoxProperties).NullStyle:=nssUnchecked;
上面的“<View>”、“<Col>”分别是cxGrid里的View名和CheckBox列的列名
<Col>.FieldName必须为空.
<Col>.Properties.imediatepost := True;//可能不是必须的
取值示例:
1. with cxGrid1DBTableView1.DataController do
begin
ShowMessage(GetDisplayText(FocusedRecordIndex,0));
ShowMessage(GetDisplayText(FocusedRowIndex,0));
ShowMessage(GetDisplayText(FocusedDataRowIndex,0));
end;
2.var
I: Integer;
begin
with cxGrid1DBTableView1.DataController do
begin
for I := 0 to RecordCount - 1 do
begin
ShowMessage(DisplayTexts[I,0]);
end;
end;
end;