Yes, you can have per item (aka node) editors:
[http://www.devexpress.com/Help/?document=XtraTreeList/CustomDocument5633.htm](http://www.devexpress.com/Help/?document=XtraTreeList/CustomDocument5633.htm)
<Sorry for the extra spaces in the following snippet>
rollout tltest "XtraTreeList Test" width: 300 height: 200
(
dotNetControl tl "DevExpress.XtraTreeList.TreeList" width: 274 height: 180
-- NOTE: I've split these long class strings because the CGTalk forums was inserting spaces...
local clsComboBox = dotNetClass ("DevExpress.XtraEditors.Repository."+"RepositoryItemComboBox")
local clsSpinEdit = dotNetClass ("DevExpress.XtraEditors.Repository."+"RepositoryItemSpinEdit")
local clsCheckEdit = dotNetClass ("DevExpress.XtraEditors.Repository."+"RepositoryItemCheckEdit")
-- Declare some custom editors for the CustomNodeCellEdit event
local riCustOdd = dotnetobject clsComboBox
local riCustEven = dotnetobject clsComboBox
on tltest open do
(
-- Set up the treelist
tl.OptionsSelection.MultiSelect = True
tl.OptionsView.ShowRoot =true
tl.OptionsView.ShowIndicator = false
tl.OptionsView.AutoWidth = false
tl.BeginUpdate();
-- Fixed the first column to the left. this is the column that contains the indented tree nodes
col = tl.Columns.Add()
col.visible = true
tl.Columns.item[0].Fixed = tl.Columns.item[0].Fixed.Left
-- Set up the 2nd column with a combo box editor
col = tl.Columns.Add()
col.visible = true
riCombo = dotnetobject clsComboBox
riCombo.Items.AddRange #("lantern", "angel", "hat", "dog" )
tl.RepositoryItems.Add riCombo
col.ColumnEdit = riCombo
-- Set up the 3rd column with a spin editor
col = tl.Columns.Add()
col.visible = true
riSpin = dotnetobject clsSpinEdit
tl.RepositoryItems.Add riSpin
col.ColumnEdit = riSpin
col.Caption = "Custom Edit"
col = tl.Columns.Add()
col.visible = true
-- The 3 columns fixed to the right are all checkboxes
riCheck = dotnetobject clsCheckEdit
tl.RepositoryItems.Add riCheck
for i = 2 to 0 by -1 do
(
col = tl.Columns.Add()
col.visible = true
col.caption = (i as string)
col.ColumnEdit = riCheck
col.Width = 5
col.Fixed = col.Fixed.Right
)
tl.EndUpdate()
tl.BeginUnboundLoad()
-- Four root level nodes
n0 = tl.AppendNode #("green","lantern" ,0, "dog", false, true, false) -1
n1 = tl.AppendNode #("blue", "angel" ,1, "rat", false, true, true) -1
n2 = tl.AppendNode #("blue", "moon" ,2 , "hawk", false, true, true) -1
n3 = tl.AppendNode #("blue", "mood" ,1, "horse", false, true, true) -1
-- Four child nodes
n00 = tl.AppendNode #("red", "hat" ,5, "turtle",false, false, true) n0
n10 = tl.AppendNode #("yellow", "dog" ,3, "gull", true, false, true) n1
n20 = tl.AppendNode #("red", "menace" ,6, "fish",false, false, true) n2
n30 = tl.AppendNode #("yellow", "streak" ,4, "rock", true, false, true) n3
tl.EndUnboundLoad()
-- Fill out the item editors used to handle
riCustEven.Items.AddRange #("111", "222", "333", "444" )
riCustOdd.Items.AddRange #("AAA", "BBB", "CCC", "DDD" )
)
on tl CustomNodeCellEdit sender evt do
(
-- Use a custom editor the 3rd column, alternating editors based on node id
-- Notice how the editor follows the node when you sort the column
if (evt.column.AbsoluteIndex == 2) do
(
evt.RepositoryItem = if mod evt.node.id 2 == 0 then riCustEven else riCustOdd
)
)
)
createdialog tltest
Imagine what you can do with a dynamically constructed per-node-popup-container-editor!
[http://www.devexpress.com/Help/?document=XtraEditors/clsDevExpressXtraEditorsPopupContainerEdittopic.htm](http://www.devexpress.com/Help/?document=XtraEditors/clsDevExpressXtraEditorsPopupContainerEdittopic.htm)
.biddle
EDIT: I just noticed that the custom editor follows the column as you drag a header around to reorder columns. Which is just what you'd expect of course since I was already testing the columns absoluteindex -- but it's cool to see it work properly right out of the can. Ya gotta love this control :)
EDIT #2: Split up the long strings in the snippet so that extra spaces wouldn’t get inserted by the code foramatter