12

点击查看代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.button1.Click += Button1_Click1;
            this.DoubleClick += Button1_DoubleClick;

            //this.WindowState = FormWindowState.Maximized;
            //this.label1.Text = thisWidth.ToString() + "  " + this.Height.ToString(); ;

            // Set the initial sorting type for the ListView.
            listView1.Sorting = SortOrder.None;
            // Disable automatic sorting to enable manual sorting.
            listView1.View = View.Details;
            // Set the view to show details.
            //listView1.View = View.Details;
            // Allow the user to edit item text.
            listView1.LabelEdit = false;
            // Allow the user to rearrange columns.
            listView1.AllowColumnReorder = false;
            // Select the item and subitems when selection is made.
            listView1.FullRowSelect = true;
            // Display grid lines.
            listView1.GridLines = true;
            // Sort the items in the list in ascending order.
            listView1.Columns.Add(new ColumnHeader());
            listView1.Columns[0].Text = "Col A";
            listView1.Columns[0].Width = 100;
            listView1.Columns[0].TextAlign = HorizontalAlignment.Left;
            listView1.Columns.Add(new ColumnHeader());
            listView1.Columns[1].Text = "Col B";
            listView1.Columns[1].Width = 140;
            listView1.Columns[1].TextAlign = HorizontalAlignment.Left;
            listView1.Columns.Add(new ColumnHeader());
            listView1.Columns[2].Text = "Col C";
            listView1.Columns[2].Width = 160;
            listView1.Columns[2].TextAlign = HorizontalAlignment.Left;
            // Suspend control logic until form is done configuring form.
            listView1.SuspendLayout();
            // Add Items to the ListView control. 
            listView1.Sorting = SortOrder.Ascending;
            // Suspend control logic until form is done configuring form.
            listView1.SuspendLayout();
            AddListViewRow("1", "2", "3");
            AddListViewRow("4", "5", "6");
            AddListViewRow("7", "8", "9");


            this.dataGridView1.GridColor = Color.Black;
        }
        public void AddListViewRow(string ColA, string COLB, string COLC)
        {
            ListViewItem NewRow = new ListViewItem(
               new string[] { ColA, COLB, COLC }, -1, Color.Empty, Color.LightSkyBlue, null);

            //Add the items to the ListView.
            listView1.Items.AddRange(new ListViewItem[] { NewRow });
        }
        private void Button1_DoubleClick(object sender, EventArgs e)
        {
            // Send the enter key; since the tab stop of Button1 is 0, this
            // will trigger the click event.
            SendKeys.SendWait("{ENTER}");
        }

        private void Button1_Click1(object sender, EventArgs e)
        {
            MessageBox.Show("Click here!");
        }
    }
}

[========]
2022-02-19 12:08:17 星期六


上一篇:Python基础 文本控制 文件编码格式 使用python读写文件 常用的文件打开方式


下一篇:flask 与 requests 的交互