TextBoxBase.Modified 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
컨트롤이 만들어졌거나 해당 내용이 마지막으로 설정된 이후 사용자가 텍스트 상자 컨트롤을 수정했음을 나타내는 값을 가져오거나 설정합니다.
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 내용과 비교합니다. 내용이 변경된 Modified 경우 속성은 .로 true설정됩니다. 그렇지 않으면 다시 설정됩니다 false. 이 예제에서는 명명 textBox1 된 TextBox 컨트롤을 만들고 String 컨트롤의 원래 텍스트를 저장하기 위해 명명 originalText 된 변수를 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 않습니다.