RichTextBox.SelectionProtected Özellik

Tanım

Geçerli metin seçiminin korunup korunmadığını belirten bir değer alır veya ayarlar.

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

Özellik Değeri

true geçerli seçim içeriğinde herhangi bir değişiklik yapılmasını engelliyorsa; aksi takdirde , false. Varsayılan değer: false.

Öznitelikler

Örnekler

Aşağıdaki kod örneği, özelliğini kullanarak SelectionProtected içindeki RichTextBox korumalı metnin nasıl belirtileceğini gösterir. Bu örnek, forma adlı richTextBox1bir RichTextBox denetimin eklenmesini ve RichTextBox denetime "RichTextBox" sözcüğünü içeren bir metin eklenmesini gerektirir.

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

Açıklamalar

Seçili metin yoksa, koruma ayarı ekleme noktasının göründüğü paragrafa ve ekleme noktasından sonra denetime yazılan tüm metne uygulanır. Koruma ayarı, özellik farklı bir değere değiştirilene veya ekleme noktası denetim içindeki farklı bir paragrafa taşınana kadar geçerlidir.

Denetim içinde metin seçilirse, seçilen metin ve metin seçiminden sonra girilen tüm metinlere bu özelliğin değeri uygulanır. Kullanıcının denetim içindeki metin bölümlerini değiştirmesini engellemek için bu özelliği kullanabilirsiniz.

Bu özellik olarak trueProtected ayarlanırsa, kullanıcı geçerli metin seçimini değiştirmeyi denediğinde olay tetikler.

Not

Bu özellik yalnızca denetimdeki seçimin tamamı korumalı içerik içeriyorsa döndürülecektir true .

Şunlara uygulanır

Ayrıca bkz.