TextBoxBase.Modified プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TextBoxBase.Modified プロパティの意味・解説 

TextBoxBase.Modified プロパティ

コントロールが作成されてから、またはコントロールが最後に設定されてから、ユーザーがテキスト ボックス コントロールを変更したかどうかを示す値を取得または設定します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説
使用例使用例

派生クラス TextBox の TextChanged イベントを使用して、コントロールにデータが入力されてから TextBox コントロールの内容が変更されたかどうかを判断するコード例を次に示します。この例では、コントロールの元の内容を格納している文字列を使用して、その文字列と TextBox の内容を比較し、内容が変更されたかどうかを判断します。内容が変更された場合は、Modified プロパティが true に設定されます。それ以外の場合は false にリセットされます。この例では、textBox1 という名前の TextBox コントロールが作成されており、TextBox コントロールの元のテキストを格納するために originalText という名前の String 変数が作成されている必要があります。

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

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 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.Equals(textBox1.get_Text()))) {
        // Set the Modified property to true to reflect the change.
        textBox1.set_Modified(true);
    }
    else {
        // Contents of textBox1 have not changed,
        // reset the Modified property.
        textBox1.set_Modified(false);
    }
} //TextBox1_TextChanged 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「TextBoxBase.Modified プロパティ」の関連用語

TextBoxBase.Modified プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TextBoxBase.Modified プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS