How to check if selected text on richtextbox that
its chars is not all bold.
For example:
notboldboldnotbold ← this is mixed.
Im not all bold ← this is not all bold
This is the code I have made, it checks selected text on richtextbox whether the text contains some bolded text or not.
its slow because its checking the char one by one using Selection.Start to Selection.Length and check if bold. If I use richTextBox1.SelectionFont.Bold
it will return false because its not all bold, that means also if its mixed with bold and not bold.
bool notallbold = true;
int start = richTextBox1.SelectionStart;
int end = richTextBox1.SelectionLength;
for (int i = 1; i < end; i++)
{
richTextBox1.SelectionStart = start+i;
richTextBox1.SelectionLength = 1;
if (richTextBox1.SelectionFont.Bold)
{
notallbold = false;
richTextBox1.SelectionStart = 0;
richTextBox1.SelectionLength = 0;
richTextBox1.SelectionStart = start;
richTextBox1.SelectionLength = end;
richTextBox1.Focus();
}
}
When checking long string, I can see the text is getting bolded when checking. Is there any efficient way than this?