TextBoxBase.Modified TextBoxBase.Modified TextBoxBase.Modified TextBoxBase.Modified Property

Definición

Obtiene o establece un valor que indica que el usuario ha modificado el control de cuadro de texto desde que se creó el control o se estableció su contenido por última vez.Gets or sets a value that indicates that the text box control has been modified by the user since the control was created or its contents were last set.

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

Valor de propiedad

true si se ha modificado el contenido del control; en caso contrario, false.true if the control's contents have been modified; otherwise, false. De manera predeterminada, es false.The default is false.

Ejemplos

En el ejemplo de código siguiente TextChanged se utiliza el TextBoxevento para un, una clase derivada, para determinar TextBox si el contenido del control ha cambiado desde que se rellenó el control con datos.The following code example uses the TextChanged event for a TextBox, a derived class, to determine if the contents of the TextBox control have changed since the control was filled with data. En el ejemplo se usa una cadena para almacenar el contenido original del control y se compara con el contenido de TextBox para determinar si el contenido ha cambiado.The example uses a string to store the original contents of the control and compares it against the contents of the TextBox to determine if the contents have changed. Si el contenido ha cambiado, la Modified propiedad se establece en true.If the contents have changed, the Modified property is set to true. De lo contrario, se restablece falseen.Otherwise, it is reset to false. Este ejemplo requiere que se TextBox haya creado textBox1 un control denominado y que se String haya creado originalText una variable denominada para almacenar el texto TextBox original del control.This example requires that a TextBox control named textBox1 has been created and that a String variable named originalText has been created to store the original text for the TextBox control.

private:
   void TextBox1_TextChanged( Object^ sender, EventArgs^ e )
   {
      /* Check to see if the change made does not return the
         control to its original state. */
      if ( originalText != textBox1->Text )
      {
         // Set the Modified property to true to reflect the change.
         textBox1->Modified = true;
      }
      else
      {
         // Contents of textBox1 have not changed, reset the Modified property.
         textBox1->Modified = false;
      }
   }
private void TextBox1_TextChanged(object sender, EventArgs e)
 {
    /* Check to see if the change made does not return the
       control to its original state. */
    if (originalText != textBox1.Text)
       // Set the Modified property to true to reflect the change.
       textBox1.Modified = true;
    else
       // Contents of textBox1 have not changed, reset the Modified property.
       textBox1.Modified = false;
 }
 
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs)
    ' Check to see if the change made does not return the
    ' control to its original state. 
    If originalText <> textBox1.Text Then
        ' Set the Modified property to true to reflect the change.
        textBox1.Modified = True
        ' Contents of textBox1 have not changed, reset the Modified property.
    Else
        textBox1.Modified = False
    End If
End Sub

Comentarios

Puede usar esta propiedad para determinar si el usuario ha modificado el contenido del control de cuadro de texto.You can use this property to determine if the user has modified the contents of the text box control. También puede establecer esta propiedad en el código para indicar que la aplicación realizó cambios en el control de cuadro de texto.You can also set this property in code to indicate that changes were made to the text box control by the application. Esta propiedad se puede utilizar en métodos de validación y de almacenamiento de datos para determinar si se han realizado cambios en un control de cuadro de texto, de modo que el contenido cambiado se pueda validar o guardar.This property can be used by validation and data-saving methods to determine if changes were made in a text box control so the changed contents can be validated or saved.

Si cambia la Text propiedad mediante programación, la Modified propiedad vuelve a false.If you change the Text property programmatically, the Modified property reverts to false. Esto no genera el ModifiedChanged evento.This does not raise the ModifiedChanged event.

Se aplica a