看看下面的示例是不是你要的 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;
记住 1. uses cxEdit 才能编译通过 2. 此示例的代码是cxTreeList1cxTreeListColumn1的OnGetEditingProperties的事件的处理代码 3. 在使用之前, 以经将cxTreeList1cxTreeListColumn1的属性Properties为Combobox, 否则 pro := cxTreeList1cxTreeListColumn1.Properties as TcxComboBoxProperties; 运行时会出错
运行的时候这句话pro := cxTreeList1cxTreeListColumn1.Properties as TcxComboBoxProperties;会出错的,然后我把它去掉就可以了。
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;
1. uses cxEdit 才能编译通过
2. 此示例的代码是cxTreeList1cxTreeListColumn1的OnGetEditingProperties的事件的处理代码
3. 在使用之前, 以经将cxTreeList1cxTreeListColumn1的属性Properties为Combobox, 否则
pro := cxTreeList1cxTreeListColumn1.Properties as TcxComboBoxProperties; 运行时会出错