帮助如何从文本文件中搜索列表视图 [英] help how to search in a listview from an text file

查看:76
本文介绍了帮助如何从文本文件中搜索列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!想知道在哪里可以找到搜索功能,以了解如何搜索保存在文本文件中的列表视图.

Hi! Would like to know where to find a search funcion for how to search to an listview that are saved in an text file.

推荐答案

如果要基于listview项,一种方法是遍历listviewitem及其子项.例如,以下内容选择了在项目或子项目中找到所需文本的所有项目.
If you want to do this based on the listview items, one way is to loop through the listviewitems and their subitems. For example the following selects all the items where desired text is found in the item or in the subitem.
foreach(ListViewItem item in mylistview.Items) {
   if (item.Text.Contains("text to search")) {
      item.Selected = true;
   }
   foreach (ListViewItem.ListViewSubItem subitem in item.SubItems) {
      if (item.Text.Contains("text to search")) {
         item.Selected = true;
      }
   }
}


这篇关于帮助如何从文本文件中搜索列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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