Aracılığıyla paylaş


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 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 denetimin RichTextBox "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. Özellik farklı bir değere değiştirilene veya ekleme noktası denetim içindeki farklı bir paragrafa taşınana kadar koruma ayarı uygulanır.

Denetim içinde metin seçilirse, seçili metin ve metin seçiminden sonra girilen metinlere bu özelliğin değeri uygulanır. Kullanıcının denetim içindeki metin bölümlerini değiştirmesini önlemek 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.

Uyarı

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

Şunlara uygulanır

Ayrıca bkz.