1.掌握主要的Windows窗体控件的功能

2.掌握使用SplitContainer控件的方法

3.掌握使用TreeView控件的方法

注:新建一个WindowsForm 命名为Form2.cs

  主要用到这四个控件:TreeView、ToolStrip、SplitContainer、ListView

在main函数中进行代码更改:

  

namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

  原先Application.Run(new Form1())改成新建的Form2也就是使用另一个窗体。在窗体2中进行修改

(1)改掉第二个窗口的名字

(2)添加Toolstrip,并选择添加的类型

通过这些控件的添加可以复习前面所学的几种基本控件。Button、Label、SplitButton、DropDownButton、Separator、ComboBox、TextBox、ProgressBar...

添加TreeView:

  目录结构:用树的思想来做,可以参考数据结构。

  树状结构中,每一个项称为标记项,标记项用一个TreeNode对象来表。右键添加根目录

此外也可以在Form的构造函数中添加代码

public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
TreeNode rootNode1 = new TreeNode("TreeRoot1");
TreeNode rootNode2 = new TreeNode("TreeRoot2");
TreeNode ChildNode1 = new TreeNode("ChildNode1");
TreeNode ChildNode2 = new TreeNode("ChildNode2");
TreeNode ChildNode3 = new TreeNode("ChildNode3");
//Add the root Nodes to the set of treeview
treeView1.Nodes.Add(rootNode1);
treeView1.Nodes.Add(rootNode2);
//add the child 1&2 to the set of the Treeroot1
rootNode1.Nodes.Add(ChildNode1);
rootNode1.Nodes.Add(ChildNode2); ChildNode2.Nodes.Add(ChildNode3); }
}

也可以实现相同的功能,此时可以去看看

  InitializeComponent();

在这个初始化的过程中,右键点击Go to defination,找到定义

// treeView1
//
this.treeView1.Location = new System.Drawing.Point(, );
this.treeView1.Name = "treeView1";
treeNode1.Name = "ChildNode1";
treeNode1.Text = "ChildNode1";
treeNode2.Name = "ChildNode3";
treeNode2.Text = "ChildNode3";
treeNode3.Name = "ChildNode2";
treeNode3.Text = "ChildNode2";
treeNode4.Name = "RootNode";
treeNode4.Text = "TreeRoot1";
treeNode5.Name = "TreeNode2";
treeNode5.Text = "TreeRoot2";
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
treeNode4,
treeNode5});
this.treeView1.Size = new System.Drawing.Size(, );
this.treeView1.TabIndex = ;
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);

这部分由Visual Studio的可视化编程软件可以自动添加。

要显示CheckBox可以将其设置为True,可以显示为勾选框

Windows窗体应用开发3--配置标准控件1的更多相关文章

  1. Windows窗体应用开发2--窗体和控件

    1.Windows窗体应用程序的各种组件 2.windows窗体控件的主要类别和功能 3.Windows窗体应用程序处理事件的方法 4.添加并配置Windows窗体和控件 5.创建时间处理程序并监视程 ...

  2. 【转】【C#】在 Windows 窗体 DataGridView 单元格中承载控件

    using System; using System.Windows.Forms; public class CalendarColumn : DataGridViewColumn { public ...

  3. C#里WinForm开发中如何实现控件随窗体大小的改变而自动适应其改变(转)

    在设计可供用户调整大小的窗体时,如何实现该窗体上的控件也应能正确地随窗体的改变而自动调整大小并且能重新定位?此时就要借助控件的.Anchor属性.Anchor属性定义控件的定位点位置.当控件锚定到某个 ...

  4. Windows Store App JavaScript 开发:WinJS库控件

    在介绍了如何使用标准的HTML控件以及WinJS库中提供的新控件之后,下面来着重介绍WinJS库中几种常用的控件. (1)ListView控件 在开发Windows应用商店应用时可以使用ListVie ...

  5. 开发类似"音速启动"的原创工具简码"万能助手"的过程中对ztree.js与win标准控件treeview、HTMLayout树形框等优缺点的比较

    在开发类似"音速启动"的桌面快捷方式管理软件简码"万能助手"的早期规划中,曾经考虑过几种树形框方案: ztree.js.win标准控件treeview.HTML ...

  6. 【Objective-C】Windows下Objective-C开发环境配置

    [Objective-C]Windows下Objective-C开发环境配置 ftp://ftpmain.gnustep.org/pub/gnustep/binaries/windows/   最近打 ...

  7. windows下spark开发环境配置

    http://www.cnblogs.com/davidwang456/p/5032766.html windows下spark开发环境配置 --本篇随笔由同事葛同学提供. windows下spark ...

  8. Metabase在Windows下的开发环境配置

    Metabase在Windows下的开发环境配置 */--> pre.src {background-color: #292b2e; color: #b2b2b2;} Metabase在Wind ...

  9. Windows标准控件

    学习目的 学习创建, 使用Windows标准控件(按钮, 滚动条, 静态控件, 列表框, 编辑框, 组合框); 学习使用子窗口控件操作函数(EnableWindow, MoveWindow, SetW ...

随机推荐

  1. eclipse - 链接hadoop

    插件: 配置:Map/Reduce Location 问题:An internal error occurred during: "Map/Reduce location status up ...

  2. maven+selenium+java+testng+jenkins自动化测试

    最近在公司搭建了一套基于maven+selenium+java+testng+jenkins的自动化测试框架,免得以后重写记录下 工程目录 pom.xml <project xmlns=&quo ...

  3. luogu P3811线性求逆元

    首先扩O:T了一个点(因为上界松),83分. #include <cstdio> using namespace std; int n, p; void exgcd(int a, int ...

  4. #6432. 「PKUSC2018」真实排名(组合数学)

    题面 传送门 题解 这数据范围--这输出大小--这模数--太有迷惑性了-- 首先对于\(0\)来说,不管怎么选它们的排名都不会变,这个先特判掉 对于一个\(a_i\)来说,如果它不选,那么所有大于等于 ...

  5. eclipse项目中的java文件导入后变为空心J问题

    1,选择工程名字右键——>属性——>JavaBuild Path会看到右侧Source标签中为空白 2,点击Add Folder...选择如图所示的src包和相关的配置文件包,点击确定: ...

  6. maven profile启动项目

  7. FileWriter 中午乱码

      解决办法 BufferedWriter writer = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (fil ...

  8. js 点击页面出现烟花 心形

    css :1 body{width:1000px; height:500px;} input{ margin:100px; width:250px; height: 50px } 3 .Firewor ...

  9. sharepoint_study_7

    描述:sharepoint网站上部署WebPart出错后,如何删除错误的WebPart?如何恢复原页面? 解决:到管理中心去将该解决方案收回并删除,可以恢复原页面,但是错误的webpart信息会保留, ...

  10. rest_framework 的验证,权限,频率

    回到顶部 快速实例 Quickstart 回到顶部 序列化 创建一个序列化类 简单使用 开发我们的Web API的第一件事是为我们的Web API提供一种将代码片段实例序列化和反序列化为诸如json之 ...