动态把列绑定属性出错了。。那一列本来是没有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;

解决方案 »

  1.   

    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的内容
      

  2.   

    好像有点答非所问.我的Field是早就绑定字段的.
      

  3.   

    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.varA: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'; 
      

  4.   

    cxGrid1DBTableView1csr_udf1_nv.PropertiesClassName :='TLookupComboBoxProperties';
        with (cxGrid1DBTableView1csr_costcenter_nv.Properties as TcxLookupComboBoxProperties) do beginPropertiesClassName :='TLookupComboBoxProperties'里的'TLookupComboBoxProperties'打错了吧,应该是'TcxLookupComboBoxProperties'