【笔记】《C#大学教程》- 第12章 GUI(二)

来源:互联网 发布:崔成国 知乎 编辑:程序博客网 时间:2024/06/04 20:26

1.菜单栏:



2.链接标签 LinkLabel:


System.Diagnostics.Process.Start("C:\\");System.Diagnostics.Process.Start("IExplore", "http://www.xxx.com");System.Diagnostics.Process.Start("notepad");

3.列表和复选列表:



//添加和移除listBox.Items.Add(item);listBox.Items.Remove(item);


4.下拉选择 ComboBox:



5.TreeView:


using System;using System.Windows.Forms;using System.IO;namespace WindowsFormsApplication4{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void Form1_Load(object sender, EventArgs e)        {            treeView1.Nodes.Add("D:\\");            PopulateTreeView("D:\\", treeView1.Nodes[0]);        }        public void PopulateTreeView(            string dir, TreeNode parentNode)        {            string[] dirArr = Directory.GetDirectories(dir);            try            {                if (dirArr.Length != 0)                {                    foreach (string directory in dirArr)                    {                        TreeNode myNode = new TreeNode(directory);                        parentNode.Nodes.Add(myNode);                        PopulateTreeView(directory, myNode);                    }                }            }            catch (UnauthorizedAccessException)            {                parentNode.Nodes.Add("Acc Denied");            }        }    }}

6.ListView:

(1).首先创建图集,选择ImageList,在List中添加图片,之后将ListView的SmallIamgeList属性设定为创建好的ImageList。



7.选项卡Tab Control:



8.多文档界面,MDI窗口:


(1).创建MDI父窗口: 将IsMdiContainer属性设置为True;

(2).创建子窗口:新建窗口类,并实例化,将MdiParent属性指定为父级窗口,并调用Show方法;

Child formchild = new Child();formchild.MdiParent = this;formchild.Show();


0 0