
如图
A窗口上的单击事件:
private void funcButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
FuncTreeDialogForm f = (FuncTreeDialogForm)App.Resolve<IFuncTreeDialogForm>();
try
{
f.ShowDialog();
}
finally
{
f.Dispose();
}
}
B窗口选择节点:
private void FuncTreeDialogForm_Load(object sender, EventArgs e)
{
this.Presenter.View = this;
IList<Model.Func> list = this.Presenter.GetFuncList();
this.treeList1.DataSource = this.Presenter.ToDataTable(list);
treeList1.OptionsBehavior.PopulateServiceColumns = false;
treeList1.KeyFieldName = "Func_Id";
treeList1.Columns["Func_Name"].Caption = "功能名称";
treeList1.ParentFieldName = "Parent_Func_Id";
this.treeList1.ExpandAll();
}
private void treeList1_DoubleClick(object sender, EventArgs e)
{
var item = this.treeList1.FocusedNode;
var ii = item.GetValue("Func_Full_Name");
MessageBox.Show(ii.ToString());
}
我现在是选择一个节点后,能弹出相应的节点全名,我想把Id和名字传给A窗口的ButtonEdit空间显示,改如何传旨??
------解决思路----------------------
在B窗体里面定义一个全局变量存储选择的节点trFocusedNode
在A中 显示B 时候 判断是否按有选择
DialogResult rs = f.ShowDialog(this);
if (rs == DialogResult.OK)
{
string stringName =f.trFocusedNode.GetValue("Func_Full_Name");
}