开发者

How do I .MatchCase and .WholeWord?

开发者 https://www.devze.com 2022-12-30 16:10 出处:网络
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

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;
          开发者_如何学Go      this.Focus();
                richTextBox1.Focus();
                findPos = richTextBox1.Find(searchText,findPos,richTextBox1.Text.Length, RichTextBoxFinds.WhatGoesHere?);

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

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


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消