How to set the edit state of a specified column in a devexpress treelist

Source: Internet
Author: User

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;
}
}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.