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

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

Button.DialogResult プロパティ

ボタンクリックしたときに親フォーム返される値を取得または設定します

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

Public Overridable Property
 DialogResult As DialogResult
Dim instance As Button
Dim value As DialogResult

value = instance.DialogResult

instance.DialogResult = value
public virtual DialogResult DialogResult { get;
 set; }
public:
virtual property DialogResult DialogResult {
    DialogResult get ();
    void set (DialogResult value);
}
/** @property */
public DialogResult get_DialogResult ()

/** @property */
public void set_DialogResult (DialogResult
 value)
public function get DialogResult
 () : DialogResult

public function set DialogResult
 (value : DialogResult)

プロパティ
DialogResult 値の 1 つ既定値None です。

例外例外
例外種類条件

InvalidEnumArgumentException

代入された値が、DialogResult 値ではありません。

解説解説

このプロパティDialogResultNone 以外の値に設定されており、親フォームが ShowDialog メソッド使用して表示されている場合ボタンクリックすると親フォーム閉じますユーザーイベントフックする必要はありません。ボタンクリックされると、フォームの DialogResult プロパティボタンDialogResult設定されます。

たとえば、"はい/いいえ/キャンセル" のダイアログ ボックス作成するには、3 つのボタン追加し、各ボタンDialogResult プロパティYesNo、および Cancel設定します

使用例使用例

Button作成し、その DialogResult プロパティOK設定してForm追加するコード例次に示します

Private Sub InitializeMyButton()
    ' Create and initialize a Button.
    Dim button1 As New Button()
    
    ' Set the button to return a value of OK when clicked.
    button1.DialogResult = DialogResult.OK
    
    ' Add the button to the form.
    Controls.Add(button1)
End Sub 'InitializeMyButton
private void InitializeMyButton()
 {
    // Create and initialize a Button.
    Button button1 = new Button();
 
    // Set the button to return a value of OK when clicked.
    button1.DialogResult = DialogResult.OK;
 
    // Add the button to the form.
    Controls.Add(button1);
 }
 
private:
   void InitializeMyButton()
   {
      // Create and initialize a Button.
      Button^ button1 = gcnew Button;
      
      // Set the button to return a value of OK when clicked.
      button1->DialogResult = ::DialogResult::OK;
      
      // Add the button to the form.
      Controls->Add( button1 );
   }
private void InitializeMyButton()
{
    // Create and initialize a Button.
    Button button1 = new Button();
    
    // Set the button to return a value of OK when clicked.
    button1.set_DialogResult(get_DialogResult().OK);
    
    // Add the button to the form.
    get_Controls().Add(button1);
} //InitializeMyButton
private function InitializeMyButton()
 {
    // Create and initialize a Button.
    var button1 : Button = new Button();
 
    // Set the button to return a value of OK when clicked.
    button1.DialogResult = System.Windows.Forms.DialogResult.OK;
 
    // Add the button to the form.
    Controls.Add(button1);
 }
 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からButton.DialogResult プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からButton.DialogResult プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からButton.DialogResult プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Button.DialogResult プロパティ」の関連用語

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

   

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



Button.DialogResult プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS