views:

33

answers:

1

Hello, 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;
            }

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

+3  A: 

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);
Hans Kesting
Thanks works great!
Tanner