RichTextBox.SelectionFont 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 텍스트 선택 영역 또는 삽입 지점의 글꼴을 가져오거나 설정합니다.
public:
property System::Drawing::Font ^ SelectionFont { System::Drawing::Font ^ get(); void set(System::Drawing::Font ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Font SelectionFont { get; set; }
[System.ComponentModel.Browsable(false)]
public System.Drawing.Font? SelectionFont { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionFont : System.Drawing.Font with get, set
Public Property SelectionFont As Font
속성 값
Font 현재 텍스트 선택 영역이나 삽입 지점 뒤에 입력된 텍스트에 적용할 글꼴을 나타내는 값입니다.
- 특성
예제
다음 코드 예제에서는 텍스트 선택 또는 컨트롤 내 RichTextBox 의 삽입 지점 뒤에 입력 된 텍스트에 대 한 현재 글꼴 굵게 스타일 설정을 변경 합니다. 이 예제에서는 코드가 .의 메서드 내에 포함되어 있어야 합니다 Form. 또한 이 예제에서는 명명
void ToggleBold()
{
if ( richTextBox1->SelectionFont != nullptr )
{
System::Drawing::Font^ currentFont = richTextBox1->SelectionFont;
System::Drawing::FontStyle newFontStyle;
if (richTextBox1->SelectionFont->Bold)
{
newFontStyle = FontStyle::Regular;
}
else
{
newFontStyle = FontStyle::Bold;
}
richTextBox1->SelectionFont = gcnew System::Drawing::Font( currentFont->FontFamily,currentFont->Size,newFontStyle );
}
}
private void ToggleBold()
{
if (richTextBox1.SelectionFont != null)
{
System.Drawing.Font currentFont = richTextBox1.SelectionFont;
System.Drawing.FontStyle newFontStyle;
if (richTextBox1.SelectionFont.Bold)
{
newFontStyle = FontStyle.Regular;
}
else
{
newFontStyle = FontStyle.Bold;
}
richTextBox1.SelectionFont = new Font(
currentFont.FontFamily,
currentFont.Size,
newFontStyle
);
}
}
Private Sub ToggleBold()
If richTextBox1.SelectionFont IsNot Nothing Then
Dim currentFont As System.Drawing.Font = richTextBox1.SelectionFont
Dim newFontStyle As System.Drawing.FontStyle
If richTextBox1.SelectionFont.Bold = True Then
newFontStyle = FontStyle.Regular
Else
newFontStyle = FontStyle.Bold
End If
richTextBox1.SelectionFont = New Font( _
currentFont.FontFamily, _
currentFont.Size, _
newFontStyle _
)
End If
End sub
설명
현재 텍스트 선택 영역에 둘 이상의 글꼴이 지정되어 있으면 이 속성은 다음과 같습니다 null. 현재 선택된 텍스트가 없으면 이 속성에 지정된 글꼴이 현재 삽입 지점 및 삽입 지점 뒤에 컨트롤에 입력된 모든 텍스트에 적용됩니다. 글꼴 설정은 속성이 다른 글꼴로 변경되거나 삽입 포인터가 컨트롤 내의 다른 섹션으로 이동할 때까지 적용됩니다.
컨트롤 내에서 텍스트를 선택하면 선택한 텍스트와 텍스트 선택 뒤에 입력된 모든 텍스트에 이 속성의 값이 적용됩니다. 이 속성을 사용하여 텍스트의 글꼴 스타일을 변경할 수 있습니다 RichTextBox. 컨트롤의 텍스트를 굵게, 기울이며, 밑줄로 만들 수 있습니다. 텍스트의 크기와 텍스트에 적용된 글꼴을 변경할 수도 있습니다.
컨트롤에서 텍스트의 색을 변경하려면 속성을 사용합니다 SelectionColor .