本文介绍了以编程方式选择listview行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有一个包含行数的listview,以及当我在textbox中编写文本时(例如:10)
那么我需要在C#.net中以编程方式在列表视图中选择任意十行
我曾经尝试过类似
Hi
I had an listview that contains number of rows ,and one textbox box when i write in textbox(eg:10)
then i need to select any ten number of rows in listview, throught programatically in C#.net
i had tried with something like
for (int i = 0; i < int.Parse(textBox1.Text); i++)
{
checkedListView.SelectedItem = checkedListView.Items[i];
}
但是通过这种方式,iam只能在listview中选择单行
所以请帮助达到此要求
but by this thing iam only able to select single row in listview
so please help to achive this requirement
thankq in advanced
推荐答案
for (int i = 0; i < int.Parse(textBox1.Text); i++)
{
checkedListView.Items[i].Selected = true;
}
int amountToSelect = 0;
int.TryParse(textBox1.Text,out amountToSelect);
for (int i = 0; i <= amountToSelect; i++)
{
listView1.Items[i].Selected = true;
}
希望对您有帮助
Hope this helps
这篇关于以编程方式选择listview行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!