C#中实现单击LISTVIEW的COLUMN进行排序的测试代码

时间:2021-05-02

在《C#中实现单击LISTVIEW的COLUMN进行排序》一文中仅给出了实现的源代码,而对于具体如何运用没有做具体介绍,本文给出了具体的应用源代码。

using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using ListViewControl;namespace SampleOnListViewControl{/// <summary>/// Summary description for Form1./// </summary>public class Form1 : System.Windows.Forms.Form{private ListViewControl.EastSpider listView1;/// <summary>/// Required designer variable./// </summary>private System.ComponentModel.Container components = null;public Form1(){//// Required for Windows Form Designer support//InitializeComponent();testfunction();//// 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.listView1 = new EastSpider();this.SuspendLayout();// // listView1// this.listView1.Location = new System.Drawing.Point(48, 32);this.listView1.Name = "listView1";this.listView1.Size = new System.Drawing.Size(256, 136);this.listView1.TabIndex = 0;// // Form1// this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);this.ClientSize = new System.Drawing.Size(376, 285);this.Controls.AddRange(new System.Windows.Forms.Control[] {this.listView1});this.Name = "Form1";this.Text = "Form1";this.ResumeLayout(false);}#endregion/// <summary>/// The main entry point for the application./// </summary>[STAThread]static void Main() {Application.Run(new Form1());}private void testfunction(){this.listView1.AddColumn("名 称",EastSpider.ColumnTypeEnum.ColumnTypeText, HorizontalAlignment.Left,187);this.listView1.AddColumn("地 址",EastSpider.ColumnTypeEnum.ColumnTypeNumber, HorizontalAlignment.Left,100);this.listView1.AddColumn("修改时间",EastSpider.ColumnTypeEnum.ColumnTypeDate, HorizontalAlignment.Left,177);this.listView1.Dock = DockStyle.Fill;this.listView1.View = System.Windows.Forms.View.Details;this.listView1.FullRowSelect = true;this.listView1.Sorting = SortOrder.Ascending;ListViewItem item1 = new ListViewItem(new string[] {"翔宇亭乐园","biye5u.com","2001-1-2 15:05"});ListViewItem item2 = new ListViewItem(new string[] {"电子邮箱,"biye5u@163.com","2009-1-3 11:04"});ListViewItem item3 = new ListViewItem(new string[] {"QQ号","48110363","2000-1-2 23:34"});this.listView1.AddRow(item1,Color.Transparent);this.listView1.AddRow(item2,Color.Transparent);this.listView1.AddRow(item3,Color.Transparent);}}}

本文源自:翔宇亭——IT乐园(http://),转载请保留此信息!

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章