TextBoxBase.Modified 속성

정의

TextBox 컨트롤을 만들거나 컨트롤의 내용을 마지막으로 설정한 이후 해당 컨트롤이 수정되었는지 여부를 나타내는 값을 가져오거나 설정합니다.

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

속성 값

컨트롤의 내용이 수정되었으면 true이고, 그렇지 않으면 false입니다. 기본값은 false입니다.

특성

예제

다음 코드 예제에서는 에 대 한 TextBox이벤트를 사용 합니다 TextChanged , 파생된 클래스를 컨트롤의 TextBox 내용이 변경 된 이후 변경 된 경우는 컨트롤 데이터로 채워집니다. 이 예제에서는 문자열을 사용하여 컨트롤의 원래 내용을 저장하고 의 내용 TextBox 과 비교하여 내용이 변경되었는지 확인합니다. 내용이 변경된 경우 속성은 Modifiedtrue설정됩니다. 그렇지 않으면 로 다시 설정 false됩니다. 이 예제에서는 라는 textBox1 컨트롤을 TextBox 만들고 라는 변수 originalTextString 만들어 컨트롤의 원래 텍스트를 TextBox 저장해야 합니다.

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

설명

이 속성을 사용하여 사용자가 텍스트 상자 컨트롤의 내용을 수정했는지 확인할 수 있습니다. 또한 애플리케이션에서 변경 내용을 텍스트 상자 컨트롤에 내용이 있는지 여부를 나타낼 코드에서이 속성을 설정할 수 있습니다. 이 속성은 유효성 검사 및 데이터 저장 메서드를 사용하여 변경된 내용의 유효성을 검사하거나 저장할 수 있도록 텍스트 상자 컨트롤에서 변경 내용이 적용되었는지 확인할 수 있습니다.

속성을 프로그래밍 방식으로 변경 Text 하면 속성이 Modified 로 되돌아갑니다 false. 이렇게 하면 이벤트가 발생하지 ModifiedChanged 않습니다.

적용 대상