switch (n)
{
case 0://删除选中的
{
if (FrmClass.Example_ListMark >= LV.SelectedIndices[0])
FrmClass.Example_ListMark = FrmClass.Example_ListMark - 1;
LV.Items[LV.SelectedIndices[0]].Remove();
break;
在if (FrmClass.Example_ListMark >= LV.SelectedIndices[0])出现如下错误:InvalidArgument=“0”的值对于“index”无效。
参数名: index
{
case 0://删除选中的
{
if (FrmClass.Example_ListMark >= LV.SelectedIndices[0])
FrmClass.Example_ListMark = FrmClass.Example_ListMark - 1;
LV.Items[LV.SelectedIndices[0]].Remove();
break;
在if (FrmClass.Example_ListMark >= LV.SelectedIndices[0])出现如下错误:InvalidArgument=“0”的值对于“index”无效。
参数名: index
// Uses the SelectedIndices property to retrieve and tally the
// price of the selected menu items.
private void ListView1_SelectedIndexChanged_UsingIndices(
object sender, System.EventArgs e)
{ ListView.SelectedIndexCollection indexes =
this.ListView1.SelectedIndices;
double price = 0.0;
foreach ( int index in indexes )
{
price += Double.Parse(
this.ListView1.Items[index].SubItems[1].Text);
} // Output the price to TextBox1.
TextBox1.Text = price.ToString();
}
参考MSDN:http://msdn.microsoft.com/zh-cn/library/system.windows.forms.listview.selectedindices.aspx
有事没事先问下MSDN 以及 Google大神之后不了解再来CSDN问.这样学习才更深刻,更有效率.
for (int j=listBox1.SelectedIndices.Count-1;j>=0;j--)
{
MessageBox.Show(listBox1.SelectedIndices[j].ToString());
}
谢谢您的建议,我会这样做的,我也一直都是这样做的,本人是一名大三学生,因考研,提前做毕业设计,对c#.net没基础,以后望各位照顾了,谢谢!