下拉树某个单元格不允许编辑。
下拉树的事件可以手动写在 load 也可以 在设置器选择。手动写代码如下:
this.treeList1.ShowingEditor += new System.ComponentModel.CancelEventHandler(this.treeList1_ShowingEditor);
方法:
private void treeList1_ShowingEditor(object sender, CancelEventArgs e)
{
//获取但是 TreeList 视图,主要 是否 TreeList 还是 GridView 看你获取的对象的类型
TreeList view = sender as TreeList;
//获取当前行数据
var currentRow = ((DataRowView)_LocationBindingSource.Current).Row as LocationDataSet.LocationRow;
//如果他的父ID为空,那么返回。
if(currentRow.IsParentIDNull())
{
return;
}
//如果你点击的单元格式 分店
if (view.FocusedColumn.FieldName == "BranchID")
{
//那么取消编辑为真,就是不能编辑
e.Cancel = true;
}
}
总结:根据什么依据不能编辑,就论自己的情况而定,ShowingEditor 是显示编辑,如果取消编辑为真
: e.Cancel = true; //就是不允许编辑