实例代码如下:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace ListViewDemo
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class DemoForm : System.Windows.Forms.Form
{
private System.Windows.Forms.ListView lvw;
private System.Windows.Forms.ImageList ilsLargeIcons;
private System.Windows.Forms.ImageList ilsSmallIcons;
private System.Windows.Forms.ComboBox cboView;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.ColumnHeader columnHeader6;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Button btnUse;
private System.Windows.Forms.Button btnLeave;
private ListViewItem itmX;
private System.Windows.Forms.Button btnStat;
const int MoneyPerHour=2;
public DemoForm()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
Windows 窗体设计器生成的代码
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace ListViewDemo
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class DemoForm : System.Windows.Forms.Form
{
private System.Windows.Forms.ListView lvw;
private System.Windows.Forms.ImageList ilsLargeIcons;
private System.Windows.Forms.ImageList ilsSmallIcons;
private System.Windows.Forms.ComboBox cboView;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.ColumnHeader columnHeader6;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Button btnUse;
private System.Windows.Forms.Button btnLeave;
private ListViewItem itmX;
private System.Windows.Forms.Button btnStat;
const int MoneyPerHour=2;
public DemoForm()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
Windows 窗体设计器生成的代码