WPF listBox中的FindString,如何? [英] FindString in WPF listBox , How?
问题描述
我如何在wpf中执行此操作?
How do i do this in wpf?
listBox1.SelectedItems.Clear();
int index = listBox1.FindString("Test");
如果(索引!= -1)
{
listBox1.SetSelected(index,true);
listBox1.TopIndex = listBox1.SelectedIndex;
}
listBox1.SelectedItems.Clear();
int index = listBox1.FindString("Test");
if (index != -1)
{
listBox1.SetSelected(index, true);
listBox1.TopIndex = listBox1.SelectedIndex;
}
推荐答案
劳里特斯!
这是代码:
int index = listBox1.Items.IndexOf("Test");
Hope it wil be useful.
请 请记住,如果有帮助,请将其标记为答案,这将帮助正在寻找相同或相似问题的解决方案的其他人.
Please remember to mark the replies as answers if they help, this will help others who are looking for solutions to the same or similar problem.
这篇关于WPF listBox中的FindString,如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!