C# treeview如何单击节点后,右边显示窗体

haoyea 2009-05-19 09:24:52
C# treeview如何单击节点后,右边显示窗体


...全文
381 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhubo_1117 2009-05-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zgke 的回复:]
你在treeView的AfterSelect事件里写

Form _Form =new Form();
_Form.Show();不就可以了..
[/Quote]
支持!
haoyea 2009-05-19
  • 打赏
  • 举报
回复
但是有好多节点,每个弹出相应的窗口
zgke 2009-05-19
  • 打赏
  • 举报
回复
你在treeView的AfterSelect事件里写

Form _Form =new Form();
_Form.Show();不就可以了..

zhushoudong 2009-05-19
  • 打赏
  • 举报
回复
做个循环不就行了啊
光宇广贞 2009-05-19
  • 打赏
  • 举报
回复
我来说一个简单的法儿:

写form类的派生类,有几种窗体就写几种派生类。

然后让树的结点和对应的窗体类一一绑定好了。

然后点哪个,就会自然而然地对应地生成所需要的窗体了。
kkun_3yue3 2009-05-19
  • 打赏
  • 举报
回复
代码仅供参考
/// <summary>
/// 显示窗口
/// </summary>
/// <param name="isCodeWindow"></param>
void OnShowWindow( bool isCodeWindow ) {
if( this.tstringTreeView.SelectedNode != null && this.tstringTreeView.SelectedNode.Tag is EntityBase ) {
this.Cursor = Cursors.WaitCursor;
EntityBase entityBase = this.tstringTreeView.SelectedNode.Tag as EntityBase;
FrmTemplateEditor frmEditor;

//先判断是否已打开该页面,有的话,直接显示之
foreach( var item in this.FrmTstring.TstringEditor.TstringDock.Documents ) {
if( item is FrmTemplateEditor ) {
frmEditor = item as FrmTemplateEditor;
if( frmEditor.TstringGuid == entityBase.Guid ) {
frmEditor.IsCodeWindow = isCodeWindow;
frmEditor.Show( this.FrmTstring.TstringEditor.TstringDock );
this.Cursor = Cursors.Default;
return;
}
}
}

//第一次打开该表的设计窗口时,新建窗口并显示
frmEditor = new FrmTemplateEditor( entityBase, this.tstringTreeView.SelectedNode, isCodeWindow );
frmEditor.Tag = this.FrmTstring;
frmEditor.Show( this.FrmTstring.TstringEditor.TstringDock );
this.Cursor = Cursors.Default;
}
}

kkun_3yue3 2009-05-19
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 haoyea 的回复:]
但是有好多节点,每个弹出相应的窗口
[/Quote]

第一次打开确实需要如此,
如果节点特别多,可以把new的窗体实例放到一个IList<yourform>列表里
下次打开时先判断有没有该实例,有的话直接show(),没有的话新增并放到列表里去
这样省些资源
CqCoder 2009-05-19
  • 打赏
  • 举报
回复
你把邮箱 给我 有需要的话
我把代码发给你··
suners 2009-05-19
  • 打赏
  • 举报
回复
hah 哈哈 学而时习之 不亦说乎
Jelly_tracy 2009-05-19
  • 打赏
  • 举报
回复
单击节点,传递相应的条件...

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧