How do I .MatchCase and .WholeWord?
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);
精彩评论