在基于Windows的应用程序中搜索 [英] Searching in a windows -based application

查看:85
本文介绍了在基于Windows的应用程序中搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上想构建一个基于Windows的应用程序,在其中放置一个名为``Search''的文本框,然后提供一些从数据库或页面进行搜索的功能,例如查找特殊的单词或字母.我可以这样做吗?

I actually want to build a windows based application in which I will put a textbox named ''Search'' and then some functionalities for Searching from the database or from the page such as to find a special word or letter.Now how can I do this?

推荐答案

如果我正确理解你的意思,那么可以这样:
if I understood you right, then smth like:
public partial class Form1 : Form
  {
      int currentIndex = 0;
      public Form1()
      {
          InitializeComponent();
      }
      private void Form1_Load(object sender, EventArgs e)
      {
          this.textBox2.Text = File.ReadAllText(@"F:\TEMP\log.txt");
      }
      private void button2_Click(object sender, EventArgs e)
      {
          this.currentIndex = this.textBox2.Text.IndexOf(this.textBox1.Text, currentIndex+1);
          this.textBox2.Select(this.currentIndex, this.textBox1.Text.Length);
          this.textBox2.Focus();
      }
  }


这篇关于在基于Windows的应用程序中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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