我如何.MatchCase和.WholeWord? [英] How do I .MatchCase and .WholeWord?

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

问题描述

我一直都做一个查找,查找下一个功能,我的richtextbox,所以让由整个单词或区分大小写或两者的用户搜索我的这些复选框,然后我拿到了前两个,工作,但我不能得到它与这两个情况下,整个单词检查工作,这是我的code:

Ive been making a find, find next function for my richtextbox, so I have these check boxes to let the user search by whole word or case sensitive or both, and I got the first two, to work but I can't get it to work with both case a whole word checked, here's my code:

if (isWhole == true && isCase == true)
            {
                string searchText = Form2.text;
                this.Focus();
                richTextBox1.Focus();
                findPos = richTextBox1.Find(searchText,findPos,richTextBox1.Text.Length, RichTextBoxFinds.WhatGoesHere?);

                richTextBox1.Select(findPos, searchText.Length);
                findPos += searchText.Length;
            }

不过,有一个为wholeword没有选择和matchcase那么有没有什么办法与.Find()?

But there's no option for wholeword and matchcase so is there any way to do this with .Find()?

推荐答案

的的 RichTextBoxFinds 是一个'标志'枚举,这意味着你可以'或'的值加在一起:

The RichTextBoxFinds is a 'flags' enum, meaning you can 'or' the values together:

findPos = richTextBox1.Find(searchText,findPos,richTextBox1.Text.Length,
   RichTextBoxFinds.WholeWord | RichTextBoxFinds.MatchCase);

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

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