Windows窗体应用开发3--配置标准控件1
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的更多相关文章
- Windows窗体应用开发2--窗体和控件
1.Windows窗体应用程序的各种组件 2.windows窗体控件的主要类别和功能 3.Windows窗体应用程序处理事件的方法 4.添加并配置Windows窗体和控件 5.创建时间处理程序并监视程 ...
- 【转】【C#】在 Windows 窗体 DataGridView 单元格中承载控件
using System; using System.Windows.Forms; public class CalendarColumn : DataGridViewColumn { public ...
- C#里WinForm开发中如何实现控件随窗体大小的改变而自动适应其改变(转)
在设计可供用户调整大小的窗体时,如何实现该窗体上的控件也应能正确地随窗体的改变而自动调整大小并且能重新定位?此时就要借助控件的.Anchor属性.Anchor属性定义控件的定位点位置.当控件锚定到某个 ...
- Windows Store App JavaScript 开发:WinJS库控件
在介绍了如何使用标准的HTML控件以及WinJS库中提供的新控件之后,下面来着重介绍WinJS库中几种常用的控件. (1)ListView控件 在开发Windows应用商店应用时可以使用ListVie ...
- 开发类似"音速启动"的原创工具简码"万能助手"的过程中对ztree.js与win标准控件treeview、HTMLayout树形框等优缺点的比较
在开发类似"音速启动"的桌面快捷方式管理软件简码"万能助手"的早期规划中,曾经考虑过几种树形框方案: ztree.js.win标准控件treeview.HTML ...
- 【Objective-C】Windows下Objective-C开发环境配置
[Objective-C]Windows下Objective-C开发环境配置 ftp://ftpmain.gnustep.org/pub/gnustep/binaries/windows/ 最近打 ...
- windows下spark开发环境配置
http://www.cnblogs.com/davidwang456/p/5032766.html windows下spark开发环境配置 --本篇随笔由同事葛同学提供. windows下spark ...
- Metabase在Windows下的开发环境配置
Metabase在Windows下的开发环境配置 */--> pre.src {background-color: #292b2e; color: #b2b2b2;} Metabase在Wind ...
- Windows标准控件
学习目的 学习创建, 使用Windows标准控件(按钮, 滚动条, 静态控件, 列表框, 编辑框, 组合框); 学习使用子窗口控件操作函数(EnableWindow, MoveWindow, SetW ...
随机推荐
- [hdu 2604] Queuing 递推 矩阵快速幂
Problem Description Queues and Priority Queues are data structures which are known to most computer ...
- jest+vue-test-utils初步实践
一.起步 1. jest Jest是 Facebook 的一套开源的 JavaScript 测试框架, 它自动集成了断言.JSDom.覆盖率报告等开发者所需要的所有测试工具,配置较少,对vue框架友好 ...
- 注解和注释以及Spring和SpringMVC常用的注解
1.两者区别 注解 :参与代码编译,以@开头的.它是给应用程序看的,单独使用注解毫无意义,一定要跟工具一起使用,这个所谓的工具实际就是能读懂注解的应用程序 注释 :对代码没有影响.对代码起到解释.说明 ...
- (原创)E - Straight Shot Gym - 101652R
解题思路:这道题的题意就是给你n,总距离X,速度v:以及n组数据:人行道的左端点和右端点,以及人行道的速度(竖直方向),如果从(0,0)到(X,0)的时间小于2X/v,则输出其时间,否则输出”Too ...
- bootstrap添加模态窗后,再弹出消息提示框后,原先的滚动条消失
设置需要滚动的模态框 overflow :scroll
- 模板【洛谷P3390】 【模板】矩阵快速幂
P3390 [模板]矩阵快速幂 题目描述 给定n*n的矩阵A,求A^k 矩阵A的大小为n×m,B的大小为n×k,设C=A×B 则\(C_{i,j}=\sum\limits_{k=1}^{n}A_{i, ...
- kuangbin专题十六 KMP&&扩展KMP POJ2752 Seek the Name, Seek the Fame
The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the l ...
- TCP通讯模型简单示例
1. TCP通讯模型 2. 服务器端 ① 创建socket,用函数socket() ② 绑定IP地址.端口号等信息到socket上,用函数bind() ③ 设置允许的最大连接数,用函数listen() ...
- oracle Clob类型转换成String类型
转载:https://www.cnblogs.com/itmyhome/p/4131339.html Clob类型转换成String类型 oracle中表结构如下: create table GRID ...
- github访问慢解决
参考:https://github.com/chenxuhua/issues-blog/issues/3 hosts文件: # GitHub Start 192.30.253.112 github.c ...