2009-07-22 6 views
0

콘텐츠가 패턴 (사실 구문 강조 표시)을 준수한다고 가정하고 내용에 따라 텍스트 상자 (또는 richtextbox)의 내용을 서식 지정하는 라이브러리가 있습니까? winform (또는 그 문제에 대해서는 WPF)을 선호하지만 이것이 웹 세계와 winform 모두에서 가능하다면 좋을 것입니다.텍스트 상자 서식 지정

+0

가능한 중복 : http://stackoverflow.com/questions/1087735/a-textbox-richtextbox-that-has-syntax-highlighting-c –

답변

1

프로그래밍 방식으로 텍스트를 선택한 다음 SelectionColor 속성을 설정하면됩니다. 물론 선택할 텍스트를 결정하는 정규 표현식을 작성해야하지만 이후에 색을 지정하는 것은 간단합니다.

오, 그래; 이 TextBox, RichTextBox (분명히) 작동하지 않습니다.

1

텍스트를 선택하고 색상을 설정하면 풍부한 텍스트 상자에서 직접이 작업을 수행 할 수 있습니다.

그러나, 당신은 윈폼을 언급 한 이후, 당신은 SyntaxEditor by ActiPro보고 할 수 있습니다 예를 들어,

... 거기에 더 정교한 라이브러리가있다.

1

이것은 약간 필요한 것입니다. 첫 번째부터 10 번째 문자 또는 RichTextBox 전체 길이를 선택하고 을 클릭 한 다음 선택 색상을 변경합니다. 키를 선택하면 전체 RichTextBox가 아닌 선택 항목이 변경됩니다. 그런 다음 글꼴을 굵게 변경할 수 있습니다. 굵은 글씨가 조금 더 이상합니다.

'select the first character 
rtbRichTextBox.SelectionStart = 0 
'Select the length forward as far as you need to 
rtbRichTextBox.SelectionLength = 10 'Len(rtbRichTextBox.Text) 

' change the text color 
rtbRichTextBox.SelectionColor = Color.Blue 

' make a highlight color over the text 
'rtbRichTextBox.SelectionBackColor = Color.Yellow 

Dim newFontStyle As System.Drawing.FontStyle 

If rtbRichTextBox.SelectionFont IsNot Nothing Then 
    newFontStyle = FontStyle.Bold 
    rtbRichTextBox.SelectionFont = New Font(MyObj_Font_Arial.FontFamily, _ 
              MyObj_Font_Arial.Size, _ 
              newFontStyle) 
end if 

'a more straight forward bold would be to change the font. 
Dim MyObjectArialFont As New Font("Arial", 6.5, FontStyle.Bold) 
rtbRichTextBox.SelectionFont = MyObjectArialFont 
관련 문제