In the work because the customer requires some special node of a column must control its editable state, so through the access to data and their own practice found can be achieved through the following steps to achieve such requirements, and now share the code.
First enable the Treelist Showingeditor event, which is called before the control is converted to an editable state, as long as the parameter of the event is set CancelEventArgs
And for the specific node can be obtained through the treelist Focusednode, and for which column can be treelist focusedcolumn to get
And my current project also requires the value of the first column to be judged, then the value of the first column is obtained by Focusednode's GetValue (0) method.
Writing so much or looking at the code might be more clear:
private void Treelist1_showingeditor (object sender, CancelEventArgs e)
{
Treelist currenttreelist = sender as Treelist;
if (currenttreelist! = null)
{
Treelistnode node = Currenttreelist.focusednode;
DevExpress.XtraTreeList.Columns.TreeListColumn column = Currenttreelist.focusedcolumn;
if (column. FieldName = = "Item_value" && node. GetValue (0). ToString ()! = "")
{
E.cancel = true;
}
Else
{
E.cancel = false;
}
}
}