|
发表于 2020-9-29 15:00:03
|
显示全部楼层
DevExpress.XtraTreeList.Nodes.TreeListNode TN;
//遍历搜索
public void GetNode(DevExpress.XtraTreeList.Nodes.TreeListNodes tc, string pSelected)
{
foreach (DevExpress.XtraTreeList.Nodes.TreeListNode TNode in tc)
{
if (TNode.GetValue(this.treeList1.KeyFieldName).ToString() == pSelected)
{
TN = TNode;
}
if (TNode.GetValue("OrganizeName").ToString() == pSelected)
{
TN = TNode;
}
GetNode(TNode.Nodes, pSelected);
}
}
private void button1_Click(object sender, EventArgs e)
{
GetNode(this.treeList1.Nodes, this.textBox1.Text);
if (TN != null)
{
//设置焦点
this.treeList1.SetFocusedNode(TN);
}
}
private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
{
DevExpress.XtraTreeList.TreeListMultiSelection mMSTN = this.treeList1.Selection;
for (int i = 0; i < mMSTN.Count; i++)
{
this.textBox1.Text = mMSTN[i][this.treeList1.KeyFieldName].ToString() + ":" + mMSTN[i][this.treeList1.ParentFieldName].ToString();
}
}
|
|