cxgrid列动态绑定属性出错。

ck_邬 2009-08-14 02:37:41
动态把列绑定属性出错了。。那一列本来是没有Properties的,我是触发某一个事件后就执行下面的语句.但listSource赋值时出错.大家来帮忙看下啊..

cxGrid1DBTableView1csr_udf1_nv.PropertiesClassName :='TLookupComboBoxProperties';
with (cxGrid1DBTableView1csr_costcenter_nv.Properties as TcxLookupComboBoxProperties) do begin
ListSource:=Ds_WorkCell; //就是这句出错,不知道什么原因
ListOptions.ShowHeader:=False;
ListFieldNames:='par_descc_nv';
KeyFieldNames:='par_descc_nv';
end;
...全文
250 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ck_邬 2009-08-15
  • 打赏
  • 举报
回复
大人们~~来救命啊。。
wxsan 2009-08-15
  • 打赏
  • 举报
回复
问题解决了就好。总一个满意的答案了吧
ck_邬 2009-08-15
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 zzzzzoperi 的回复:]
cxGrid1DBTableView1csr_udf1_nv.PropertiesClassName :='TLookupComboBoxProperties';
    with (cxGrid1DBTableView1csr_costcenter_nv.Properties as TcxLookupComboBoxProperties) do begin

PropertiesClassName :='TLookupComboBoxProperties'里的'TLookupComboBoxProperties'打错了吧,应该是'TcxLookupComboBoxProperties'
[/Quote]
最后竟然是你找到答案。。D版的朋友怎么不对我的贴多多关注啊。。
zzzzzoperi 2009-08-15
  • 打赏
  • 举报
回复
cxGrid1DBTableView1csr_udf1_nv.PropertiesClassName :='TLookupComboBoxProperties';
with (cxGrid1DBTableView1csr_costcenter_nv.Properties as TcxLookupComboBoxProperties) do begin

PropertiesClassName :='TLookupComboBoxProperties'里的'TLookupComboBoxProperties'打错了吧,应该是'TcxLookupComboBoxProperties'
ck_邬 2009-08-15
  • 打赏
  • 举报
回复
就没人在我基础上指出错误吗?
zzzzzoperi 2009-08-15
  • 打赏
  • 举报
回复
等待答案公报中
zyblotuszyb 2009-08-15
  • 打赏
  • 举报
回复
TcxLookupComboBoxProperties.ListSource
Specifies the TDataSource instance containing data to display within a lookup editor.

property ListSource: TDataSource;

Description
Use the ListSource property to specify the TDataSource instance containing data to display within a lookup editor. Setting this property value is not enough for the lookup editor to display data within the dropdown list. The lookup editor must have at least one column in the ListColumns collection bound to a specific ListSource field.

Also you have to specify a key field(s) via the KeyFieldNames property used to identify records within the ListSource. A key field value(s) of a record selected in the dropdown list matches the edit value of an editor and can be accessed via the EditValue property.
The value displayed in the edit region of a lookup combobox is addressed by the ListFieldIndex property.

var

A:TDataSource:
B:TcxlookupcomboboxProperties;
begin
A:=TDataSource.create(self);
B:=tcxlookupcomboboxproperties.create(self);
A.Dataset:=Dic_ry_xb;//此处指定数据源。
b.listdource:=a;//此处指明字段的listsource属性。
b.keyfieldnames:='a'; //此处指明字段的关键字段
b.listfieldnames:='b'; //此处指明字段的返回值。
b.listcolumns.items[0].caption:='x; //此处默认是会建立一个字段,但是显示的表头是name,所以此处让它显示为自己想要的中午显示。
cxGrid1DBTableView1c1_sex_code.Properties:=b; //此处指明是那个字段。
end; //这个是初始化的代码,


cxGrid1DBTableView1AID.PropertiesClass :=
TcxLookupComboBoxProperties;
with TcxLookupComboBoxProperties(cxGrid1DBTableView1AID.Properties) do
begin
ListSource := datasappraise;
KeyFieldNames := 'AID';
ListFieldNames := 'AID;AItems;Ales';
//;proportion
ListColumns[0].Caption:='编号';
ListColumns[0].FieldName:='AID';
ListColumns[1].Caption:='项目';
ListColumns[1].FieldName:='AItems';
ListColumns[2].Caption:='细则';
ListColumns[2].FieldName:='Ales';
//ListColumns[3].Caption:='比重';
//ListColumns[3].FieldName:='proportion';
end;
cxGrid1DBTableView1AID.DataBinding.FieldName := 'AID';
ck_邬 2009-08-14
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 mrwangfei 的回复:]
var I:integer;
begin
  Cxgrid1DBTableView1.ClearItems;
  for I:=0 to QryExcut.FieldCount-1 do
  begin
    Cxgrid1DBTableView1.CreateColumn;
    Cxgrid1DBTableView1.Columns[i].DataBinding.FieldName:=QryExcut.Fields[i].FieldName;
  end;
  //以上是动态画显示cxgrid的内容
[/Quote]
好像有点答非所问.我的Field是早就绑定字段的.
22222bbb 2009-08-14
  • 打赏
  • 举报
回复
var I:integer;
begin
Cxgrid1DBTableView1.ClearItems;
for I:=0 to QryExcut.FieldCount-1 do
begin
Cxgrid1DBTableView1.CreateColumn;
Cxgrid1DBTableView1.Columns[i].DataBinding.FieldName:=QryExcut.Fields[i].FieldName;
end;
//以上是动态画显示cxgrid的内容

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧