错误提示:InvalidArgument=“1”的值对于“index”无效。 感觉程序上做的没有错希望有这方面经验的朋友们,进来指点一下,谢谢了~本人在线等,问题解决就给分。
解决方案 »
- 请教高手,奇怪问题.
- webBrowser1控件的使用
- c# windows api 对象结构?描述可能不准确,请高手指点。
- 在程序1的窗体A上怎么调用API函数来控制程序2的窗体A???
- DoWork 事件完了为何出异常
- 高手进__关于对象序列化的问题(分不够我再补!)
- 在ASP.NET中调用REMOTING会出错,WINDOWFORM就不会,为什么,是安全问题吗??请进
- 200分求一个好的c#语言开发的开源的erp系统,哪位有的,给我一个!谢谢!
- 如果设置winform置顶
- 在asp.net中用datalist显示数据库的文本,不能显示回车,全为一行 呢!
- socket的问题
- *******怎么改变TextBox控件的高度
{
listView2.Items[ii].SubItems.Add(File.GetCreationTime(listView2.Items[ii].Text).ToString());
}。
再来就是MSDN的了。
private int sortColumn = -1; this.listView2.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listView2_ColumnClick);private void listView2_ColumnClick(object sender, ColumnClickEventArgs e)
{
// Determine whether the column is the same as the last column clicked.
if (e.Column != sortColumn)
{
// Set the sort column to the new column.
sortColumn = e.Column;
// Set the sort order to ascending by default.
listView1.Sorting = SortOrder.Ascending;
}
else
{
// Determine what the last sort order was and change it.
if (listView1.Sorting == SortOrder.Ascending)
listView1.Sorting = SortOrder.Descending;
else
listView1.Sorting = SortOrder.Ascending;
}
// Call the sort method to manually sort.
listView1.Sort();
// Set the ListViewItemSorter property to a new ListViewItemComparer
// object.
this.listView1.ListViewItemSorter = new ListViewItemComparer(e.Column,
listView1.Sorting);
} class ListViewItemComparer : IComparer
{
private int col;
private SortOrder order;
public ListViewItemComparer()
{
col = 0;
order = SortOrder.Ascending;
}
public ListViewItemComparer(int column, SortOrder order)
{
col = column;
this.order = order;
}
public int Compare(object x, object y)
{
int returnVal;
// Determine whether the type being compared is a date type.
//try
//{
// Parse the two objects passed as a parameter as a DateTime.
System.DateTime firstDate =
DateTime.Parse(((ListViewItem)x).SubItems[col].Text);
System.DateTime secondDate =
DateTime.Parse(((ListViewItem)y).SubItems[col].Text);
// Compare the two dates.
returnVal = DateTime.Compare(firstDate, secondDate);
//}
// If neither compared object has a valid date format, compare
// as a string.
//catch
//{
// Compare the two items as a string.
returnVal = String.Compare(((ListViewItem)x).SubItems[col].Text,
((ListViewItem)y).SubItems[col].Text);
//}
// Determine whether the sort order is descending.
if (order == SortOrder.Descending)
// Invert the value returned by String.Compare.
returnVal *= -1;
return returnVal;
}
}
我看你的代码中,好像只有SubItem是DateTime格式的文本,而Item.Text可能就不是了.如果你点的是这一列可能就出错了.