Windows Forms RichTextBox 컨트롤의 일반적인 용도는 글꼴 옵션 또는 단락 스타일과 같은 특성으로 텍스트 서식을 지정하는 것입니다. 애플리케이션은 많은 워드 프로세싱 응용 프로그램에서와 같이 도구 모음을 표시하기 위해 텍스트 서식의 변경 내용을 추적해야 할 수 있습니다.
서식 특성의 변경 내용에 응답하려면
특성 값에 따라 적절한 작업을 수행하기 위해 SelectionChanged 이벤트 처리기에 코드를 작성합니다. 다음은 SelectionBullet 속성 값에 따라 도구 모음 단추의 모양을 변경하는 예제입니다. 도구 모음 단추는 컨트롤에서 삽입 지점을 이동할 때만 업데이트됩니다.
아래 예제에서는 RichTextBox 컨트롤이 있는 양식과 도구 모음 단추가 포함된 ToolBar 컨트롤을 가정합니다. 도구 모음 및 도구 모음 단추에 대한 자세한 내용은 방법: 도구 모음 컨트롤에 단추 추가를 참조하세요.
' The following code assumes the existence of a toolbar control ' with at least one toolbar button. Private Sub RichTextBox1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.SelectionChanged If RichTextBox1.SelectionBullet = True Then ' Bullet button on toolbar should appear pressed ToolBarButton1.Pushed = True Else ' Bullet button on toolbar should appear unpressed ToolBarButton1.Pushed = False End If End Sub
// The following code assumes the existence of a toolbar control // with at least one toolbar button. private void richTextBox1_SelectionChanged(object sender, System.EventArgs e) { if (richTextBox1.SelectionBullet == true) { // Bullet button on toolbar should appear pressed toolBarButton1.Pushed = true; } else { // Bullet button on toolbar should appear unpressed toolBarButton1.Pushed = false; } }
// The following code assumes the existence of a toolbar control // with at least one toolbar button. private: System::Void richTextBox1_SelectionChanged( System::Object ^ sender, System::EventArgs ^ e) { if (richTextBox1->SelectionBullet == true) { // Bullet button on toolbar should appear pressed toolBarButton1->Pushed = true; } else { // Bullet button on toolbar should appear unpressed toolBarButton1->Pushed = false; } }
참고하십시오
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET Desktop feedback