CommonDialog.ShowDialog 메서드

정의

일반 대화 상자를 실행합니다.

오버로드

Name Description
ShowDialog()

기본 소유자와 함께 공통 대화 상자를 실행합니다.

ShowDialog(IWin32Window)

지정된 소유자와 함께 공통 대화 상자를 실행합니다.

ShowDialog()

Source:
CommonDialog.cs
Source:
CommonDialog.cs
Source:
CommonDialog.cs
Source:
CommonDialog.cs
Source:
CommonDialog.cs

기본 소유자와 함께 공통 대화 상자를 실행합니다.

public:
 System::Windows::Forms::DialogResult ShowDialog();
public System.Windows.Forms.DialogResult ShowDialog();
member this.ShowDialog : unit -> System.Windows.Forms.DialogResult
Public Function ShowDialog () As DialogResult

반품

OK사용자가 대화 상자에서 확인을 클릭하면 이고, 그렇지 않으면 . Cancel

예제

다음 코드 예제에서는 구현 ColorDialogCommonDialog 사용하며 대화 상자를 만들고 표시하는 방법을 보여 줍니다. 이 예제에서는 메서드를 기존 폼 내에서 호출해야 합니다. 이 양식에는 TextBox 메서드가 있고 Button 해당 폼에 배치되어 있어야 합니다.

private:
   void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      ColorDialog^ MyDialog = gcnew ColorDialog;
      // Keeps the user from selecting a custom color.
      MyDialog->AllowFullOpen = false;
      // Allows the user to get help. (The default is false.)
      MyDialog->ShowHelp = true;
      // Sets the initial color select to the current text color.
      MyDialog->Color = textBox1->ForeColor;
      
      // Update the text box color if the user clicks OK 
      if ( MyDialog->ShowDialog() == ::System::Windows::Forms::DialogResult::OK )
      {
         textBox1->ForeColor = MyDialog->Color;
      }
   }
private void button1_Click(object sender, System.EventArgs e)
 {
    ColorDialog MyDialog = new ColorDialog();
    // Keeps the user from selecting a custom color.
    MyDialog.AllowFullOpen = false ;
    // Allows the user to get help. (The default is false.)
    MyDialog.ShowHelp = true ;
    // Sets the initial color select to the current text color.
    MyDialog.Color = textBox1.ForeColor ;
    
    // Update the text box color if the user clicks OK 
    if (MyDialog.ShowDialog() == DialogResult.OK)
        textBox1.ForeColor =  MyDialog.Color;
 }
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim MyDialog As New ColorDialog()
    ' Keeps the user from selecting a custom color.
    MyDialog.AllowFullOpen = False
    ' Allows the user to get help. (The default is false.)
    MyDialog.ShowHelp = True
    ' Sets the initial color select to the current text color,
    MyDialog.Color = TextBox1.ForeColor

    ' Update the text box color if the user clicks OK 
    If (MyDialog.ShowDialog() = DialogResult.OK) Then
        TextBox1.ForeColor = MyDialog.Color
    End If
End Sub

설명

이 메서드는 RunDialog를 구현합니다.

추가 정보

적용 대상

ShowDialog(IWin32Window)

Source:
CommonDialog.cs
Source:
CommonDialog.cs
Source:
CommonDialog.cs
Source:
CommonDialog.cs
Source:
CommonDialog.cs

지정된 소유자와 함께 공통 대화 상자를 실행합니다.

public:
 System::Windows::Forms::DialogResult ShowDialog(System::Windows::Forms::IWin32Window ^ owner);
public System.Windows.Forms.DialogResult ShowDialog(System.Windows.Forms.IWin32Window owner);
public System.Windows.Forms.DialogResult ShowDialog(System.Windows.Forms.IWin32Window? owner);
member this.ShowDialog : System.Windows.Forms.IWin32Window -> System.Windows.Forms.DialogResult
Public Function ShowDialog (owner As IWin32Window) As DialogResult

매개 변수

owner
IWin32Window

모달 대화 상자를 소유할 최상위 창을 나타내는 개체 IWin32Window 입니다.

반품

OK사용자가 대화 상자에서 확인을 클릭하면 이고, 그렇지 않으면 . Cancel

설명

이 버전의 ShowDialog 메서드를 사용하면 표시되는 대화 상자를 소유할 특정 폼이나 컨트롤을 지정할 수 있습니다. 매개 변수가 없는 이 메서드 버전을 사용하는 경우 표시되는 대화 상자는 애플리케이션의 현재 활성 창에서 자동으로 소유됩니다.

적용 대상