public void SelectListIndex(ListControl lc,string values)
{
string[] tempValues = values.Split(',');
if (tempValues.Length > 0)
{
foreach (string tempvalue in tempValues)
foreach (ListItem li in lc.Items)
{
if (li.Value == tempvalue)
li.Selected = true;
}
}
}
{
string[] tempValues = values.Split(',');
if (tempValues.Length > 0)
{
foreach (string tempvalue in tempValues)
foreach (ListItem li in lc.Items)
{
if (li.Value == tempvalue)
li.Selected = true;
}
}
}
本文介绍了一种方法,用于根据给定的值列表来设置列表控件中项目的选中状态。通过将输入字符串按逗号拆分,并遍历列表控件的所有项进行匹配,实现指定值的自动选中。
166

被折叠的 条评论
为什么被折叠?



