如何隐藏和显示树视图左侧菜单项? [英] How Can I Hide And Show The Tree View Left Side Menu Item ?

查看:193
本文介绍了如何隐藏和显示树视图左侧菜单项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows Mdi Parent窗体的左侧有Tree View Control。如何隐藏和显示树视图控件。(例如:Visual Studio TOOL BOX方法)。请帮助我。

I have Tree View Control on Left side in a Windows Mdi Parent form . How can i Hide and Show the Tree view control.(eg: Visual Studio TOOL BOX Method). Please Help Me.

推荐答案

imho,Windows MDI应用程序结构现在是一种化石,我鼓励你考虑编写一个应用程序有多个独立的表格。但是,事实仍然是很多人仍在使用MDI,并且许多学生被分配了要求他们编写MDI应用程序的项目。



在Windows MDI架构中,你应该直接向MDIParentForm 添加控件;它们将模糊(显示在)所有MDIChild Windows的边界框与之相交。



引擎盖MdiParentForm托管另一个特殊类型的窗口:System.Windows.Forms.MdiClient。当你创建一个新的Form实例MDICarentForm的MDIChild时,Form被添加到MdiClient的ControlCollection。



考虑这个:创建一个MDIChildForm来保存TreeView ,并使用其Dock或Anchor,Properties将其定位在您想要的位置。



如果您定义了两个表单,'ChildForm1和'ChildForm2,以及表单'ChildForm1有一个停靠在其中的TreeView:您的MDIParentForm加载事件可能如下所示:

imho, Windows MDI application structure is kind of a "fossil" these days, and I would encourage you to, instead, consider writing an application with multiple independent Forms. But, the fact remains that a lot of people are still using MDI, and many students are being assigned projects requiring them to write MDI applications.

In the Windows MDI architecture, you should not add Controls to the MDIParentForm directly; they will obscure (be shown in front of) all MDIChild Windows their bounding-boxes intersect with.

Under-the-hood the MdiParentForm hosts another Window of a special Type: "System.Windows.Forms.MdiClient." When you make a new instance of a Form the MDIChild of an MDIParentForm, the Form is added to the MdiClient's ControlCollection.

Consider this: create one MDIChildForm to hold the TreeView, and use its Dock, or Anchor, Properties to position it where you want it to be.

If you defined two Forms, 'ChildForm1, and 'ChildForm2, and Form 'ChildForm1 had a TreeView docked inside it: your MDIParentForm Load event might look like this:
ChildForm1 child1 = new ChildForm1();
ChildForm2 child2 = new ChildForm2();

private void MdiParentForm_Load(object sender, System.EventArgs e)
{
    // hide the close box ?
    child1.ControlBox = false;
    // borderless, without Caption ?
    child1.FormBorderStyle = FormBorderStyle.FixedToolWindow;
    child1.Text = "";

    child1.MdiParent = this;
    child1.Dock = DockStyle.Left;

    child2.MdiParent = this;
    child2.Dock = DockStyle.Right;

    child1.Show();
    child2.Show();     
}


这篇关于如何隐藏和显示树视图左侧菜单项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆