简单的问题,高手进来帮小弟一把~!!!!
C:\Documents and Settings\miller.net\My Documents\Visual Studio Projects\个人名片夹\Form1.cs(275): 运算符“==”无法应用于“System.Windows.Forms.ColumnHeader”和“string”类型的操作数
C:\Documents and Settings\miller.net\My Documents\Visual Studio Projects\个人名片夹\Form1.cs(268): 与“System.Windows.Forms.ListViewItem.ListViewSubItem.ListViewSubItem(System.Windows.Forms.ListViewItem, string)”最匹配的重载方法具有一些无效参数
C:\Documents and Settings\miller.net\My Documents\Visual Studio Projects\个人名片夹\Form1.cs(245): 名称“sort”在类或命名空间“个人名片夹.Form1”中不存在
C:\Documents and Settings\miller.net\My Documents\Visual Studio Projects\个人名片夹\Form1.cs(248): 名称“sort”在类或命名空间“个人名片夹.Form1”中不存在
C:\Documents and Settings\miller.net\My Documents\Visual Studio Projects\个人名片夹\Form1.cs(253): 名称“sort”在类或命名空间“个人名片夹.Form1”中不存在
C:\Documents and Settings\miller.net\My Documents\Visual Studio Projects\个人名片夹\Form1.cs(250): 名称“sort”在类或命名空间“个人名片夹.Form1”中不存在
C:\Documents and Settings\miller.net\My Documents\Visual Studio Projects\个人名片夹\Form1.cs(268): 参数“2” : 无法从“System.Windows.Forms.ColumnHeader”转换为“string”
不知道这些错误是怎么回事,怎么解决。高手指点一下 ,叩谢了!!!!
部分源代码是这样子的:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace 个人名片夹
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.ColumnHeader name;
private System.Windows.Forms.ColumnHeader phone;
private System.Windows.Forms.ColumnHeader email;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void listView1_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e)
{
if (sort==false)
{
this.listView1.Sorting=SortOrder.Ascending;
sort=true;
}
else if(sort==true)
{
this.listView1.Sorting=SortOrder.Descending;
sort=false;
}
}
private void button1_Click(object sender, System.EventArgs e)
{
String name=this.textBox1.Text;
String photo=this.textBox2.Text;
String email=this.textBox3.Text;
if (name!=""&photo!=""&email!="")
{
int number=this.listView1.Items.Count;
ListViewItem lvItem= new ListViewItem(new ListViewItem.ListViewSubItem[]
{
new ListViewItem.ListViewSubItem(null,name),
new ListViewItem.ListViewSubItem(null,phone),
new ListViewItem.ListViewSubItem(null,email)
},-1);
this.listView1.Items.Insert(number,lvItem);
this.listView1.Items[number].ImageIndex=0;
}
else if(name==""){MessageBox.Show("请输入姓名","警告");}
else if(phone==""){MessageBox.Show("请输入电话号码","警告");}
else if(email==""){MessageBox.Show("请输入邮件地址","警告");}
}
private void button2_Click(object sender, System.EventArgs e)
{
this.textBox1.Text="";
this.textBox2.Text="";
this.textBox3.Text="";
}
private void button3_Click(object sender, System.EventArgs e)
{
ListViewItem li=this.listView1.SelectedItems[0];
this.listView1.Items.Remove(li);
}
}
}