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

📄 form1.cs

📁 《c#技术内幕代码》
💻 CS
字号:
namespace CH7_12
{
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.WinForms;
    using System.Data;

    /// <summary>
    ///    Summary description for Form1.
    /// </summary>
    public class Form1 : System.WinForms.Form
    {
        /// <summary>
        ///    Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components;
		private SeagateSoftware.WinForms.CrystalReportViewer crystalReportViewer1;
		private System.WinForms.ImageList imageList1;
		private System.WinForms.RadioButton radioButton2;
		private System.WinForms.RadioButton radioButton1;
		private System.WinForms.GroupBox groupBox1;
		private System.WinForms.Button button2;
		private System.WinForms.Button button1;
		private System.WinForms.ListView listView1;

        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>
        public override void Dispose()
        {
            base.Dispose();
            components.Dispose();
        }

        /// <summary>
        ///    Required method for Designer support - do not modify
        ///    the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager (typeof(Form1));
			this.components = new System.ComponentModel.Container ();
			this.groupBox1 = new System.WinForms.GroupBox ();
			this.button2 = new System.WinForms.Button ();
			this.radioButton2 = new System.WinForms.RadioButton ();
			this.radioButton1 = new System.WinForms.RadioButton ();
			this.crystalReportViewer1 = new SeagateSoftware.WinForms.CrystalReportViewer ();
			this.button1 = new System.WinForms.Button ();
			this.listView1 = new System.WinForms.ListView ();
			this.imageList1 = new System.WinForms.ImageList ();
			//@this.TrayHeight = 90;
			//@this.TrayLargeIcon = false;
			//@this.TrayAutoArrange = true;
			groupBox1.Location = new System.Drawing.Point (8, 120);
			groupBox1.TabIndex = 3;
			groupBox1.TabStop = false;
			groupBox1.Text = "groupBox1";
			groupBox1.Size = new System.Drawing.Size (112, 120);
			button2.Location = new System.Drawing.Point (16, 56);
			button2.Size = new System.Drawing.Size (88, 24);
			button2.TabIndex = 2;
			button2.Text = "&Remove";
			button2.Click += new System.EventHandler (this.button2_Click);
			radioButton2.Location = new System.Drawing.Point (8, 48);
			radioButton2.Text = "Icons";
			radioButton2.Size = new System.Drawing.Size (72, 23);
			radioButton2.TabIndex = 1;
			radioButton2.CheckedChanged += new System.EventHandler (this.radioButton2_CheckedChanged);
			radioButton1.Location = new System.Drawing.Point (8, 24);
			radioButton1.Text = "Report";
			radioButton1.Size = new System.Drawing.Size (88, 23);
			radioButton1.TabIndex = 0;
			radioButton1.CheckedChanged += new System.EventHandler (this.radioButton1_CheckedChanged);
			crystalReportViewer1.Text = "crystalReportViewer1";
			crystalReportViewer1.Size = new System.Drawing.Size (150, 150);
			crystalReportViewer1.ActiveViewIndex = -1;
			crystalReportViewer1.TabIndex = 0;
			button1.Location = new System.Drawing.Point (16, 16);
			button1.Size = new System.Drawing.Size (88, 24);
			button1.TabIndex = 1;
			button1.Text = "&Add";
			button1.Click += new System.EventHandler (this.button1_Click);
			listView1.Location = new System.Drawing.Point (128, 8);
			listView1.Size = new System.Drawing.Size (304, 248);
			listView1.ForeColor = System.Drawing.SystemColors.WindowText;
			listView1.TabIndex = 0;
			//@imageList1.SetLocation (new System.Drawing.Point (7, 7));
			imageList1.ImageSize = new System.Drawing.Size (16, 16);
			imageList1.ImageStream = (System.WinForms.ImageListStreamer) resources.GetObject ("imageList1.ImageStream");
			imageList1.ColorDepth = System.WinForms.ColorDepth.Depth8Bit;
			imageList1.TransparentColor = System.Drawing.Color.Transparent;
			this.Text = "List View";
			this.AutoScaleBaseSize = new System.Drawing.Size (5, 13);
			this.ClientSize = new System.Drawing.Size (552, 273);
			groupBox1.Controls.Add (this.radioButton2);
			groupBox1.Controls.Add (this.radioButton1);
			this.Controls.Add (this.groupBox1);
			this.Controls.Add (this.button2);
			this.Controls.Add (this.button1);
			this.Controls.Add (this.listView1);
		}

		protected void radioButton2_CheckedChanged (object sender, System.EventArgs e)
		{
           this.listView1.View = View.LargeIcon;
		}

		protected void radioButton1_CheckedChanged (object sender, System.EventArgs e)
		{
            this.listView1.View = View.Report;
		}

		protected void button2_Click (object sender, System.EventArgs e)
		{
            this.listView1.ListItems.Remove(0);
		}

		protected void button1_Click (object sender, System.EventArgs e)
		{
			string[] subitems1 = 
			{
				"Sub1.1",
				"Sub1.2",
				"Sub1.3"
			};
			string[] subitems2 = 
			{
				"Sub2.1",
				"Sub2.2",
				"Sub2.3"
			};
			string[] subitems3 = 
			{
				"Sub3.1",
				"Sub3.2",
				"Sub3.3"
			};
			string[] subitems4 = 
			{
				"Sub4.1",
				"Sub4.2",
				"Sub4.3"
			};

            this.listView1.ListItems.Add("Item 1", 0, subitems1 );
            this.listView1.ListItems.Add("Item 2", 1, subitems2 );
            this.listView1.ListItems.Add("Item 3", 2, subitems3 );
            this.listView1.ListItems.Add("Item 4", 3, subitems4 );

			this.listView1.LargeImageList = this.imageList1;

			// Add the column headers
			this.listView1.Columns.Add("Title", 150, 
				HorizontalAlignment.Center );
			this.listView1.Columns.Add("Sub 1", 75, 
				HorizontalAlignment.Center );
			this.listView1.Columns.Add("Sub 2", 75, 
				HorizontalAlignment.Center );
			this.listView1.Columns.Add("Sub 3", 50, 
				HorizontalAlignment.Center );
		}

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

⌨️ 快捷键说明

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