繁体中文
设为首页
加入收藏
当前位置:.Net技术首页 >> Asp.Net开发 >> 抛砖引玉——实现LISTVIEW点击COLUMN排序的代码,可实现按时间,字符,数字排序(测试

抛砖引玉——实现LISTVIEW点击COLUMN排序的代码,可实现按时间,字符,数字排序(测试

2007-07-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using ListViewControl; namespace SampleOnListViewControl {...

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using ListViewControl;

namespace SampleOnListViewControl

{

///

/// Summary description for Form1.

///

public class Form1 : System.Windows.Forms.Form

{

private ListViewControl.EastSpider listView1;

///

/// Required designer variable.

///

private System.ComponentModel.Container components = null;

public Form1()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

testfunction();

//

// TODO: Add any constructor code after InitializeComponent call

//

}

///

/// Clean up any resources being used.

///

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

///

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

///

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

///

/// The main entry point for the application.

///

[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[] {"aaa","100","2001-1-2 15:05"});

ListViewItem item2 = new ListViewItem(new string[] {"bbb","200","2001-1-3 11:04"});

ListViewItem item3 = new ListViewItem(new string[] {"ccc","300","2002-1-2 23:34"});

this.listView1.AddRow(item1,Color.Transparent);

this.listView1.AddRow(item2,Color.Transparent);

this.listView1.AddRow(item3,Color.Transparent);

}

}

}

责任编辑:admin
相关文章