using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;namespace Client
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.TextBox textBox1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null) 
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.listView1 = new System.Windows.Forms.ListView();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
// 
// listView1
// 
this.listView1.FullRowSelect = true;
this.listView1.Location = new System.Drawing.Point(8, 8);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(280, 336);
this.listView1.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.listView1.TabIndex = 4;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
// 
// textBox1
// 
this.textBox1.Location = new System.Drawing.Point(296, 256);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(416, 21);
this.textBox1.TabIndex = 5;
this.textBox1.Text = "textBox1";
// 
// Form1
// 
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(728, 486);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.listView1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main() 
{
Application.Run(new Form1());
} private void Form1_Load(object sender, System.EventArgs e)
{ //init ListView control
this.listView1.Clear(); //clear control
//create column header for ListView
this.listView1.Columns.Add("col1",100,System.Windows.Forms.HorizontalAlignment.Left);
this.listView1.Columns.Add("col2",100,System.Windows.Forms.HorizontalAlignment.Left); string [] lvData = new string[2]; lvData[0] = "aaa";
lvData[1] = "bbb";
ListViewItem lvItem = new ListViewItem(lvData,0);
this.listView1.Items.Add(lvItem); lvData[0] = "ccc";
lvData[1] = "ddd";
lvItem = new ListViewItem(lvData,0);
this.listView1.Items.Add(lvItem);
lvData[0] = "eee";
lvData[1] = "fff";
lvItem = new ListViewItem(lvData,0);
this.listView1.Items.Add(lvItem);
} private void listView1_SelectedIndexChanged(object sender, System.EventArgs e)
{
try
{
this.textBox1.Text = this.listView1.SelectedItems[0].Text.ToString();

}
catch(Exception ee)
{
MessageBox.Show(ee.ToString());
}
} }
}//只个private void listView1_SelectedIndexChanged(object sender, System.EventArgs e)
事件到底应该怎么写才能不断地选也不会错呢?