我需要将CanCheck设置为true或false,具体取决于BeforeCheckNode事件中的ForeColor of Node。如何在BeforeCheckNode事件中获取e.Node的ForeColor?
private void _tree_BeforeCheckNode(object sender, DevExpress.XtraTreeList.CheckNodeEventArgs e)
{
int index = _tree.GetNodeIndex(e.Node);
RowInfo ri = _tree.ViewInfo.RowsInfo.Rows[index] as RowInfo;
CellInfo cell = (CellInfo)ri.Cells[0];
if (cell.PaintAppearance.ForeColor == Color.LightGray)
e.CanCheck = false;
}
但这里索引是相对于父母的。因此,如果我有多个具有子节点的父节点,则RowInfo出错。如果我使用可见索引,它将不适用于RowInfo,因为它超出了范围。
答案 0 :(得分:0)
if ((_tree.ViewInfo.RowsInfo[e.Node].Cells[0] as CellInfo).PaintAppearance.ForeColor == Color.LightGray)
e.CanCheck = false;
解决了我的问题。