简单的问题,高手进来帮小弟一把~!!!!

lijun521 2004-06-29 10:54:08
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);
}
}
}
...全文
126 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
lijun521 2004-07-02
  • 打赏
  • 举报
回复
历史问题看来是没人会看了
lijun521 2004-07-01
  • 打赏
  • 举报
回复
sort要定义吗? 怎么定义
baker_gw 2004-06-30
  • 打赏
  • 举报
回复
namespace 个人名片夹?
名称空间可以用中文吗?
lijun521 2004-06-30
  • 打赏
  • 举报
回复
顶一下
lijun521 2004-06-30
  • 打赏
  • 举报
回复
我的代码帖的有点乱 不好意思了

主要就是两个问题

1.不能识别sort这个变量,是什么原因?????

2.在电话号码输入框(textbox)里面,好象数值形和字符型有冲突

就是这两个问题 小弟刚开始学习dotnet 高手教我 谢谢了谢谢了
Piyongcai 2004-06-30
  • 打赏
  • 举报
回复
lijun521 2004-06-30
  • 打赏
  • 举报
回复
namespace 个人名片夹?
名称空间可以用中文吗?


这个是没关系的吧~~~
Bigenius 2004-06-30
  • 打赏
  • 举报
回复
sort没定义啊!晕~
lijun521 2004-06-30
  • 打赏
  • 举报
回复
哎~
yy_will 2004-06-29
  • 打赏
  • 举报
回复
与是 &&

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧