在使用TcxTreeList的时候,添加一个列之后,设置该列的属性Properties为Combobox,然后我需要动态加载它的Items。
  请问怎么样动态加载,研究了一两天了,还是不知道怎么做!
  请各位大虾帮帮忙,等着要用的,谢谢!

解决方案 »

  1.   

    看看下面的示例是不是你要的
    procedure TForm1.cxTreeList1cxTreeListColumn1GetEditingProperties(
      Sender: TcxTreeListColumn; ANode: TcxTreeListNode;
      var EditProperties: TcxCustomEditProperties);
    var
      pro: TcxComboBoxProperties;
      curNode: TcxTreeListNode;
      i: Integer;
    begin
      pro := cxTreeList1cxTreeListColumn1.Properties as TcxComboBoxProperties;
      pro.Items.Clear;
      EditProperties := Pro;
      curNode := ANode;
      if curNode = nil then exit;
      if curNode.Index mod 2 = 0 then
      begin
        for i := 0 to 10 do
          pro.Items.Add(IntToStr(i*2));
      end
      else
      begin
        for i := 0 to 10 do
          pro.Items.Add(IntToStr(i*2 + 1));
      end;
    end;
      

  2.   

    记住
    1. uses cxEdit 才能编译通过
    2. 此示例的代码是cxTreeList1cxTreeListColumn1的OnGetEditingProperties的事件的处理代码
    3. 在使用之前, 以经将cxTreeList1cxTreeListColumn1的属性Properties为Combobox, 否则
    pro := cxTreeList1cxTreeListColumn1.Properties as TcxComboBoxProperties; 运行时会出错
      

  3.   

    运行的时候这句话pro := cxTreeList1cxTreeListColumn1.Properties as TcxComboBoxProperties;会出错的,然后我把它去掉就可以了。