RichTextBox.SelectionProtected 속성

정의

현재 텍스트 선택 영역이 보호되는지 여부를 나타내는 값을 가져오거나 설정합니다.

public:
 property bool SelectionProtected { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public bool SelectionProtected { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionProtected : bool with get, set
Public Property SelectionProtected As Boolean

속성 값

현재 선택 영역의 내용을 변경할 수 없으면 true이고, 그렇지 않으면 false입니다. 기본값은 false입니다.

특성

예제

다음 코드 예제를 사용 하 여 내에서 RichTextBox 보호 된 텍스트를 지정 하는 방법을 보여 줍니다는 SelectionProtected 속성입니다. 이 예제에서는 라는 richTextBox1컨트롤이 RichTextBox 폼에 추가되고 컨트롤에 RichTextBox "RichTextBox"라는 단어가 포함된 텍스트가 추가되어야 합니다.

private:
   void ProtectMySelectedText()
   {
      // Determine if the selected text in the control contains the word "RichTextBox".
      if (  !richTextBox1->SelectedText->Equals( "RichTextBox" ) )
      {
         // Search for the word RichTextBox in the control.
         if ( richTextBox1->Find( "RichTextBox", RichTextBoxFinds::WholeWord ) == -1 )
         {
            //Alert the user that the word was not foun and return.
            MessageBox::Show( "The text \"RichTextBox\" was not found!" );
            return;
         }
      }

      // Protect the selected text in the control from being altered.
      richTextBox1->SelectionProtected = true;
   }
private void ProtectMySelectedText()
{
   // Determine if the selected text in the control contains the word "RichTextBox".
   if(richTextBox1.SelectedText != "RichTextBox")
   {
      // Search for the word RichTextBox in the control.
      if(richTextBox1.Find("RichTextBox",RichTextBoxFinds.WholeWord)== -1)
      {
         //Alert the user that the word was not foun and return.
         MessageBox.Show("The text \"RichTextBox\" was not found!");
         return;
      }
   }
   // Protect the selected text in the control from being altered.
   richTextBox1.SelectionProtected = true;
}
Private Sub ProtectMySelectedText()
   ' Determine if the selected text in the control contains the word "RichTextBox".
   If richTextBox1.SelectedText <> "RichTextBox" Then
      ' Search for the word RichTextBox in the control.
      If richTextBox1.Find("RichTextBox", RichTextBoxFinds.WholeWord) = -1 Then
         'Alert the user that the word was not foun and return.
         MessageBox.Show("The text ""RichTextBox"" was not found!")
         Return
      End If
   End If
   ' Protect the selected text in the control from being altered.
   richTextBox1.SelectionProtected = True
End Sub

설명

현재 선택된 텍스트가 없으면 삽입 지점이 표시되는 단락과 삽입 지점 뒤에 컨트롤에 입력된 모든 텍스트에 보호 설정이 적용됩니다. 보호 설정은 속성이 다른 값으로 변경되거나 삽입 지점이 컨트롤 내의 다른 단락으로 이동할 때까지 적용됩니다.

컨트롤 내에서 텍스트를 선택하면 선택한 텍스트와 텍스트 선택 뒤에 입력된 모든 텍스트에 이 속성의 값이 적용됩니다. 사용자가 컨트롤 내에서 텍스트 섹션을 수정하지 못하도록 하려면 이 속성을 사용할 수 있습니다.

이 속성을 로 trueProtected 설정하면 사용자가 현재 텍스트 선택을 변경하려고 할 때 이벤트가 발생합니다.

참고

이 속성은 컨트롤 내의 전체 선택 영역에 보호된 콘텐츠가 포함된 경우에만 반환 true 됩니다.

적용 대상

추가 정보