为什么我写的ListViewItem lvi = new ListViewItem(); 必须要有参数才行?

卧槽这是我的昵称吗 2013-08-27 02:23:09
ListViewItem lvi = new ListViewItem();
错误 “System.Web.UI.WebControls.ListViewItem”不包含采用“0”个参数的构造函数

但是我在网上随便找的例子,都是这样写的啊,没见new ListViewItem(); 还带了参数的

而且msdn上

ListView listView1 = new ListView();
listView1.Bounds = new Rectangle(new Point(10,10), new Size(300,200));

// Set the view to show details.
listView1.View = View.Details;
// Allow the user to edit item text.
listView1.LabelEdit = true;
// Allow the user to rearrange columns.
listView1.AllowColumnReorder = true;
// Display check boxes.
listView1.CheckBoxes = true;
// Select the item and subitems when selection is made.
listView1.FullRowSelect = true;
// Display grid lines.
listView1.GridLines = true;
// Sort the items in the list in ascending order.
listView1.Sorting = SortOrder.Ascending;


而我放在本地写算么listView1.AllowColumnReorder这些属性压根就没有啊?
...全文
323 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
雪狐 2013-08-27
  • 打赏
  • 举报
回复
汗。。。。。
全栈极简 2013-08-27
  • 打赏
  • 举报
回复
你看错了。winform的listview有AllowColumnReorder,你的是webform的,没有AllowColumnReorder。
  • 打赏
  • 举报
回复
引用 2 楼 guwei4037 的回复:
ListView lv = new ListView(); lv.AllowColumnReorder = true; 是可以的。注意大小写。
“System.Web.UI.WebControls.ListView”不包含“AllowColumnReorder”的定义,并且找不到可接受类型为“System.Web.UI.WebControls.ListView”的第一个参数的扩展方法“AllowColumnReorder”(是否缺少 using 指令或程序集引用? 我真的不明白。。。
全栈极简 2013-08-27
  • 打赏
  • 举报
回复
ListView lv = new ListView();
lv.AllowColumnReorder = true;
是可以的。注意大小写。
本拉灯 2013-08-27
  • 打赏
  • 举报
回复
你找的是WINFORM的代码。。

111,098

社区成员

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

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

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