richtextbox 텍스트의 마지막 '{'과 '}'사이에있는 텍스트를 선택하고 싶습니다. 다음 코드가 있지만 "LastIndexOf"함수에 오류가있어서이를 수정하는 방법을 모르겠습니다. 누군가 나에게 도움을 줄 수 있습니까?C#의 리치 텍스트 상자에서 텍스트 선택
private void highlightText()
{
mRtbxOperations.SelectionStart = mRtbxOperations.Text.LastIndexOf(@"{", 1, mRtbxOperations.SelectionStart);
mRtbxOperations.SelectionLength = mRtbxOperations.Text.IndexOf(@"}", mRtbxOperations.SelectionStart, mRtbxOperations.Text.Length - 1);
mRtbxOperations.SelectionBackColor = Color.LightBlue;
mRtbxOperations.SelectionFont = new Font(mRtbxOperations.SelectionFont, FontStyle.Underline);
mRtbxOperations.SelectionLength = 0;
}
lastIndexOf에서도 오류 :
The count must be positive and must refer to a location within the string, array or collection. Parameter name: count
가능한 중복 (http://stackoverflow.com/questions/455713/selectively-coloring-text-in-richtextbox) –