WPF listBox中的FindString,如何? [英] FindString in WPF listBox , How?

查看:69
本文介绍了WPF listBox中的FindString,如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在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

在Twitter上关注我: 


这篇关于WPF listBox中的FindString,如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆