that is the standard way and listed in Windows.Forms FAQ:23.5 How do I programmatically select an item in my listview? http://www.syncfusion.com/FAQ/WinForms/FAQ_c90c.asp#q797q
有没有哪位高人能提供使用ListView的技巧?
using System; class IndexerClass { private int [] myArray = new int[100]; public int this [int index] // 注意,在这里声明索引器 { get { if (index < 0 || index >= 100) return 0; else return myArray[index]; } set { if (!(index < 0 || index >= 100)) myArray[index] = value; } } }public class MainClass { public static void Main() { IndexerClass b = new IndexerClass(); // 在这里使用索引器 b[3] = 256; b[5] = 1024; for (int i=0; i<=10; i++) { Console.WriteLine("Element #{0} = {1}", i, b[i]); } } }
listView1.Items[i].Selected=true;
http://www.syncfusion.com/FAQ/WinForms/FAQ_c90c.asp#q797q
class IndexerClass
{
private int [] myArray = new int[100];
public int this [int index] // 注意,在这里声明索引器
{
get
{
if (index < 0 || index >= 100)
return 0;
else
return myArray[index];
}
set
{
if (!(index < 0 || index >= 100))
myArray[index] = value;
}
}
}public class MainClass
{
public static void Main()
{
IndexerClass b = new IndexerClass();
// 在这里使用索引器
b[3] = 256;
b[5] = 1024;
for (int i=0; i<=10; i++)
{
Console.WriteLine("Element #{0} = {1}", i, b[i]);
}
}
}