我试图创建一个程序来运行特定的应用程序,这是在ListView中选择的。我有一个在我的应用程序和DoubleClick事件的代号为SoftView的ListView如下:ListView异常:System.ArgumentOutOfRangeException:参数超出范围
private void SoftView_DoubleClick(object sender, EventArgs e)
{
...
if (SoftView.Items[SoftView.SelectedIndices[0]].SubItems[0].Text == "Application name")
{
...
-- Run selected application --
Application.Exit();
}
}
在执行时,我有以下异常:
System.ArgumentOutOfRangeException:参数超出范围。
参数名称:索引
在System.Windows.Forms.ListView + SelectedIndexCollection.get_Item(的Int32索引)[0x00000]
在Launcher.MainForm.SoftView_DoubleClick(System.Object的发件人,发送System.EventArgs E)[0x00000]
在System.Windows.Forms.Control.OnDoubleClick(System.EventArgs发送)[0x00000]
在System.Windows.Forms.ListView + ItemControl.HandleClicks(System.Windows.Forms的.MouseEventArgs我)[0x0000 0]
在System.Windows.Forms.ListView + ItemControl.ItemsMouseUp(System.Object的发件人,System.Windows.Forms.MouseEventArgs我)[0x00000]
在System.Windows.Forms.Control.OnMouseUp (System.Windows.Forms.MouseEventArgs E)[0x00000]
在System.Windows.Forms.Control.WmLButtonUp(System.Windows.Forms.Message &米)[0x00000]
在System.Windows。 Forms.Control.WndProc(System.Windows.Forms.Message & m)[0x00000]
在System.Windows.Forms.ListView + ItemControl.WndProc(System.Windows.Forms.Message &米)[0x00000]
在System.Windows.Forms.Control的+ ControlWindowTarget.OnMessage(System.Windows。 Forms.Message &米)[0x00000]
在System.Windows.Forms.Control的+ ControlNativeWindow.WndProc(System.Windows.Forms.Message &米)[0x00000]
在System.Windows.Forms的。 NativeWindow.WndProc(IntPtr hWnd,Msg msg,IntPtr wParam,IntPtr lParam)[0x00000]
有谁知道如何解决这个问题? 在此先感谢。
这是实现分选一个ListView的最佳途径。如果你想改变你的排序功能,可以看看这里的例子。 http://support.microsoft。com/kb/319401 – CharithJ 2011-06-16 04:55:35