RichTextBox.SelectionProtected Propiedad

Definición

Obtiene o establece un valor que indica si la selección de texto actual está protegida.

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

Valor de propiedad

Es true si la selección actual impide que se realicen cambios en el contenido; en caso contrario es false. De manera predeterminada, es false.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo especificar texto protegido dentro de mediante RichTextBox la SelectionProtected propiedad . En este ejemplo se requiere que se haya agregado un RichTextBox control, denominado richTextBox1, al formulario y que el RichTextBox control tenga texto agregado que contenga la palabra "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

Comentarios

Si no hay texto seleccionado actualmente, la configuración de protección se aplica al párrafo en el que aparece el punto de inserción y a todo el texto que se escribe en el control después del punto de inserción. La configuración de protección se aplica hasta que la propiedad cambia a un valor diferente o hasta que el punto de inserción se mueve a un párrafo diferente dentro del control.

Si se selecciona texto dentro del control, el texto seleccionado y cualquier texto escrito después de la selección de texto tendrá aplicado el valor de esta propiedad. Puede usar esta propiedad para evitar que el usuario modifique secciones de texto dentro del control.

Si esta propiedad se establece trueen , el Protected evento se genera cuando el usuario intenta cambiar la selección de texto actual.

Nota:

Esta propiedad solo devolverá true si toda la selección dentro del control contiene contenido protegido.

Se aplica a

Consulte también