⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 Sams Teach Yourself C# Web Programming in 21 Days source codes.
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Lists_and_Trees
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class fclsListsAndTrees : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ImageList imgMyImages;
		private System.Windows.Forms.ListView lvwMyListView;
		private System.Windows.Forms.ColumnHeader columnHeader1;
		private System.Windows.Forms.ColumnHeader columnHeader2;
		private System.Windows.Forms.TreeView tvwLanguages;
		private System.Windows.Forms.Button btnAddNode;
		private System.Windows.Forms.Button btnCreateChild;
		private System.ComponentModel.IContainer components;

		public fclsListsAndTrees()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(fclsListsAndTrees));
			System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem(new System.Windows.Forms.ListViewItem.ListViewSubItem[] {
																																								new System.Windows.Forms.ListViewItem.ListViewSubItem(null, "James Foxall", System.Drawing.SystemColors.WindowText, System.Drawing.SystemColors.Window, new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)))),
																																								new System.Windows.Forms.ListViewItem.ListViewSubItem(null, "Nebraska")}, 0);
			this.imgMyImages = new System.Windows.Forms.ImageList(this.components);
			this.lvwMyListView = new System.Windows.Forms.ListView();
			this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
			this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
			this.tvwLanguages = new System.Windows.Forms.TreeView();
			this.btnAddNode = new System.Windows.Forms.Button();
			this.btnCreateChild = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// imgMyImages
			// 
			this.imgMyImages.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
			this.imgMyImages.ImageSize = new System.Drawing.Size(16, 16);
			this.imgMyImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imgMyImages.ImageStream")));
			this.imgMyImages.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// lvwMyListView
			// 
			this.lvwMyListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																							this.columnHeader1,
																							this.columnHeader2});
			this.lvwMyListView.FullRowSelect = true;
			this.lvwMyListView.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
																						  listViewItem1});
			this.lvwMyListView.Location = new System.Drawing.Point(8, 8);
			this.lvwMyListView.Name = "lvwMyListView";
			this.lvwMyListView.Size = new System.Drawing.Size(275, 97);
			this.lvwMyListView.SmallImageList = this.imgMyImages;
			this.lvwMyListView.TabIndex = 0;
			this.lvwMyListView.View = System.Windows.Forms.View.Details;
			// 
			// columnHeader1
			// 
			this.columnHeader1.Text = "Name";
			this.columnHeader1.Width = 120;
			// 
			// columnHeader2
			// 
			this.columnHeader2.Text = "State";
			// 
			// tvwLanguages
			// 
			this.tvwLanguages.ImageList = this.imgMyImages;
			this.tvwLanguages.Location = new System.Drawing.Point(8, 128);
			this.tvwLanguages.Name = "tvwLanguages";
			this.tvwLanguages.Size = new System.Drawing.Size(272, 97);
			this.tvwLanguages.TabIndex = 1;
			// 
			// btnAddNode
			// 
			this.btnAddNode.Location = new System.Drawing.Point(8, 240);
			this.btnAddNode.Name = "btnAddNode";
			this.btnAddNode.TabIndex = 2;
			this.btnAddNode.Text = "Add Node";
			this.btnAddNode.Click += new System.EventHandler(this.btnAddNode_Click);
			// 
			// btnCreateChild
			// 
			this.btnCreateChild.Location = new System.Drawing.Point(96, 240);
			this.btnCreateChild.Name = "btnCreateChild";
			this.btnCreateChild.Size = new System.Drawing.Size(80, 23);
			this.btnCreateChild.TabIndex = 3;
			this.btnCreateChild.Text = "Create Child";
			this.btnCreateChild.Click += new System.EventHandler(this.btnCreateChild_Click);
			// 
			// fclsListsAndTrees
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 273);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.btnCreateChild,
																		  this.btnAddNode,
																		  this.tvwLanguages,
																		  this.lvwMyListView});
			this.Name = "fclsListsAndTrees";
			this.Text = "Lists and Trees";
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new fclsListsAndTrees());
		}

		private void btnAddNode_Click(object sender, System.EventArgs e)
		{
			tvwLanguages.Nodes.Add("Sam Chun");
			tvwLanguages.Nodes.Add("C#");

		}

		private void btnCreateChild_Click(object sender, System.EventArgs e)
		{
			TreeNode objNode;
			objNode = tvwLanguages.Nodes.Add("Sam Chun");
			objNode.Nodes.Add("C#");

		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -