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

📄 form1.cs

📁 李振峰 vb2005 源码 下载 请多支持
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Sample
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
		private Sample.TreeViewBound treeViewBound1;
		private System.Windows.Forms.Button button2;
		private System.ComponentModel.IContainer components;

		public Form1()
		{
			//
			// 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(Form1));
			this.button1 = new System.Windows.Forms.Button();
			this.imageList1 = new System.Windows.Forms.ImageList(this.components);
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
			this.treeViewBound1 = new Sample.TreeViewBound();
			this.button2 = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(0, 264);
			this.button1.Name = "button1";
			this.button1.TabIndex = 1;
			this.button1.Text = "GO!";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// imageList1
			// 
			this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// dataGrid1
			// 
			this.dataGrid1.DataMember = "";
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(272, 8);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.Size = new System.Drawing.Size(272, 240);
			this.dataGrid1.TabIndex = 2;
			this.dataGrid1.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
																								  this.dataGridTableStyle1});
			// 
			// dataGridTableStyle1
			// 
			this.dataGridTableStyle1.DataGrid = this.dataGrid1;
			this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGridTableStyle1.MappingName = "";
			// 
			// treeViewBound1
			// 
			this.treeViewBound1.DisplayMember = null;
			this.treeViewBound1.ImageIndex = -1;
			this.treeViewBound1.Location = new System.Drawing.Point(0, 8);
			this.treeViewBound1.Name = "treeViewBound1";
			this.treeViewBound1.ParentMember = null;
			this.treeViewBound1.RootParentValue = ((object)(resources.GetObject("treeViewBound1.RootParentValue")));
			this.treeViewBound1.SelectedImageIndex = -1;
			this.treeViewBound1.Size = new System.Drawing.Size(264, 240);
			this.treeViewBound1.TabIndex = 4;
			this.treeViewBound1.ValueMember = null;
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(464, 264);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(80, 23);
			this.button2.TabIndex = 5;
			this.button2.Text = "Sort selected";
			this.button2.Click += new System.EventHandler(this.button2_Click_1);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(544, 293);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.treeViewBound1);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.button1);
			this.Name = "Form1";
			this.Text = "Form1";
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}
		DataTable dt;
		private void button1_Click(object sender, System.EventArgs e)
		{
			dt = new DataTable("Table");
			dt.Columns.Add("ID", typeof(int));
			dt.Columns.Add("IDParent", typeof(int));
			dt.Columns.Add("Name", typeof(string));
			dt.Rows.Add(new object[]{1, 2, null});
			dt.Rows.Add(new object[]{2, DBNull.Value, "Sports News"});
			dt.Rows.Add(new object[]{3, 2, "Rugby"});
			dt.Rows.Add(new object[]{4, 1, "Amateur Soccer"});
			dt.Rows.Add(new object[]{5, 1, "Proffesional Soccer"});
			dt.Rows.Add(new object[]{6, DBNull.Value, "International News"});
			dt.AcceptChanges();

			this.dataGrid1.DataSource = dt;

			this.treeViewBound1.ValueMember = "ID";
			this.treeViewBound1.ParentMember = "IDParent";
			this.treeViewBound1.DisplayMember = "Name";
			this.treeViewBound1.DataSource = dt;
		}

		private void button2_Click_1(object sender, System.EventArgs e)
		{
			if (this.treeViewBound1.SelectedNode != null)
			{
				((TreeNodeBound)this.treeViewBound1.SelectedNode).SortChilds();
			}
		}
	}
}

⌨️ 快捷键说明

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