다음을 통해 공유


Control.DoubleClick 이벤트

컨트롤을 두 번 클릭하면 발생합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Event DoubleClick As EventHandler
‘사용 방법
Dim instance As Control
Dim handler As EventHandler

AddHandler instance.DoubleClick, handler
public event EventHandler DoubleClick
public:
event EventHandler^ DoubleClick {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
/** @event */
public void add_DoubleClick (EventHandler value)

/** @event */
public void remove_DoubleClick (EventHandler value)
JScript에서는 이벤트를 사용할 수 있지만 새로 선언할 수는 없습니다.

설명

두 번 클릭(double-click)은 사용자 운영 체제의 마우스 설정에 따라 결정됩니다. 천천히 두 번 클릭하는 것이 아닌 두 번 클릭(double-click)으로 간주될 수 있도록 마우스 단추 클릭 간격을 설정할 수 있습니다. 컨트롤을 두 번 클릭할 때마다 Click 이벤트가 발생합니다. 예를 들어, FormClickDoubleClick 이벤트에 대한 이벤트 처리기가 있는 경우 폼을 두 번 클릭하면 ClickDoubleClick 이벤트가 발생하고 두 메서드가 모두 호출됩니다. DoubleClick 이벤트를 지원하지 않는 컨트롤을 두 번 클릭하면 Click 이벤트가 두 번 발생할 수 있습니다.

이 이벤트를 발생시키려면 ControlStylesStandardDoubleClickStandardClick 값을 true로 설정해야 합니다. 기존의 Windows Forms 컨트롤에서 상속을 받은 경우에는 이러한 값이 이미 true로 설정되어 있을 수 있습니다.

참고

TabControl.TabPages 컬렉션에 TabPage가 하나 이상 있어야만 TabControl 클래스에 대해 Click, DoubleClick, MouseDown, MouseUp, MouseHover, MouseEnter, MouseLeaveMouseMove 이벤트가 발생합니다. 컬렉션에 TabPage가 하나 이상 있는 경우 사용자가 TabPage 이름이 나타나는 탭 컨트롤의 머리글과 상호 작용하면 TabControl에서 해당 이벤트를 발생시킵니다. 그러나 사용자 상호 작용이 탭 페이지의 클라이언트 영역 내에 있는 경우 TabPage는 해당 이벤트를 발생시킵니다.

이벤트 처리에 대한 자세한 내용은 이벤트 사용을 참조하십시오.

상속자 참고 사항 표준 Windows Forms 컨트롤에서 상속하고 ControlStylesStandardClick 또는 StandardDoubleClick 값을 true로 변경한 경우 해당 컨트롤이 Click 또는 DoubleClick 이벤트를 지원하지 않으면 예상치 못한 동작이 발생하거나 아무런 결과도 나타나지 않을 수 있습니다. 다음 표에서는 Windows Forms 컨트롤과 지정된 마우스 동작에 대한 응답으로 발생하는 이벤트(Click 또는 DoubleClick)를 보여 줍니다.

컨트롤

마우스 왼쪽 단추 클릭

마우스 왼쪽 단추 두 번 클릭

마우스 오른쪽 단추 클릭

마우스 오른쪽 단추 두 번 클릭

마우스 가운데 단추 클릭

마우스 가운데 단추 두 번 클릭

XButton1 마우스 클릭

XButton1 마우스 두 번 클릭

XButton2 마우스 클릭

Xbutton2 마우스 두 번 클릭

MonthCalendar,

DateTimePicker,

RichTextBox,

HScrollBar,

VScrollBar

없음

없음

없음

없음

없음

없음

없음

없음

없음

없음

Button,

CheckBox,

RadioButton

클릭

클릭, 클릭

없음

없음

없음

없음

없음

없음

없음

없음

ListBox,

CheckedListBox,

ComboBox

클릭

클릭, 두 번 클릭

없음

없음

없음

없음

없음

없음

없음

없음

TextBox,

DomainUpDown,

NumericUpDown

클릭

클릭, 두 번 클릭

없음

없음

없음

없음

없음

없음

없음

없음

* TreeView,

* ListView

클릭

클릭, 두 번 클릭

클릭

클릭, 두 번 클릭

없음

없음

없음

없음

없음

없음

ProgressBar,

TrackBar

클릭

클릭, 클릭

클릭

클릭, 클릭

클릭

클릭, 클릭

클릭

클릭, 클릭

클릭

클릭, 클릭

Form,

DataGrid,

Label,

LinkLabel,

Panel,

GroupBox,

PictureBox,

Splitter,

StatusBar,

ToolBar,

TabPage,

** TabControl

클릭

클릭, 두 번 클릭

클릭

클릭, 두 번 클릭

클릭

클릭, 두 번 클릭

클릭

클릭, 두 번 클릭

클릭

클릭, 두 번 클릭

* 마우스 포인터가 자식 개체(TreeNode 또는 ListViewItem) 위에 있어야 합니다. ** TabControl의 해당 TabPages 컬렉션에는 하나 이상의 TabPage가 있어야 합니다.

예제

다음 코드 예제에서는 ListBoxDoubleClick 이벤트를 사용하여 ListBox에 나열된 텍스트 파일을 TextBox 컨트롤에 나열합니다.

' This example uses the DoubleClick event of a ListBox to load text files  
' listed in the ListBox into a TextBox control. This example
' assumes that the ListBox, named listBox1, contains a list of valid file 
' names with path and that this event handler method
' is connected to the DoublClick event of a ListBox control named listBox1.
' This example requires code access permission to access files.
Private Sub listBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles listBox1.DoubleClick
    ' Get the name of the file to open from the ListBox.
    Dim file As [String] = listBox1.SelectedItem.ToString()

    Try
        ' Determine if the file exists before loading.
        If System.IO.File.Exists(file) Then
            ' Open the file and use a TextReader to read the contents into the TextBox.
            Dim myFile As New System.IO.FileInfo(listBox1.SelectedItem.ToString())
            Dim myData As System.IO.TextReader = myFile.OpenText()

            textBox1.Text = myData.ReadToEnd()
            myData.Close()
        End If
        ' Exception is thrown by the OpenText method of the FileInfo class.
    Catch
        MessageBox.Show("The file you specified does not exist.")
        ' Exception is thrown by the ReadToEnd method of the TextReader class.
    Catch
     MessageBox.Show("There was a problem loading the file into the TextBox. Ensure that the file is a valid text file.")
    End Try
End Sub
// This example uses the DoubleClick event of a ListBox to load text files
// listed in the ListBox into a TextBox control. This example
// assumes that the ListBox, named listBox1, contains a list of valid file
// names with path and that this event handler method
// is connected to the DoublClick event of a ListBox control named listBox1.
// This example requires code access permission to access files.
private void listBox1_DoubleClick(object sender, System.EventArgs e)
{
    // Get the name of the file to open from the ListBox.
    String file = listBox1.SelectedItem.ToString();

    try
    {
        // Determine if the file exists before loading.
        if (System.IO.File.Exists(file))
        {
            // Open the file and use a TextReader to read the contents into the TextBox.
            System.IO.FileInfo myFile = new System.IO.FileInfo(listBox1.SelectedItem.ToString());
            System.IO.TextReader myData = myFile.OpenText();;

            textBox1.Text = myData.ReadToEnd();
            myData.Close();
        }
    }
        // Exception is thrown by the OpenText method of the FileInfo class.
    catch(System.IO.FileNotFoundException)
    {
        MessageBox.Show("The file you specified does not exist.");
    }
        // Exception is thrown by the ReadToEnd method of the TextReader class.
    catch(System.IO.IOException)
    {
        MessageBox.Show("There was a problem loading the file into the TextBox. Ensure that the file is a valid text file.");
    }
}
   // This example uses the DoubleClick event of a ListBox to load text files
   // listed in the ListBox into a TextBox control. This example
   // assumes that the ListBox, named listBox1, contains a list of valid file
   // names with path and that this event handler method
   // is connected to the DoublClick event of a ListBox control named listBox1.
   // This example requires code access permission to access files.
private:
   void listBox1_DoubleClick( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      // Get the name of the file to open from the ListBox.
      String^ file = listBox1->SelectedItem->ToString();
      try
      {
         // Determine if the file exists before loading.
         if ( System::IO::File::Exists( file ) )
         {
            
            // Open the file and use a TextReader to read the contents into the TextBox.
            System::IO::FileInfo^ myFile = gcnew System::IO::FileInfo( listBox1->SelectedItem->ToString() );
            System::IO::TextReader^ myData = myFile->OpenText();
            ;
            textBox1->Text = myData->ReadToEnd();
            myData->Close();
         }
      }
      // Exception is thrown by the OpenText method of the FileInfo class.
      catch ( System::IO::FileNotFoundException^ ) 
      {
         MessageBox::Show( "The file you specified does not exist." );
      }
      // Exception is thrown by the ReadToEnd method of the TextReader class.
      catch ( System::IO::IOException^ ) 
      {
         MessageBox::Show( "There was a problem loading the file into the TextBox. Ensure that the file is a valid text file." );
      }
   }
// This example uses the DoubleClick event of a ListBox to load text files
// listed in the ListBox into a TextBox control. This example
// assumes that the ListBox, named listBox1, contains a list of valid file
// names with path and that this event handler method
// is connected to the DoublClick event of a ListBox control named listBox1.
// This example requires code access permission to access files.
private void listBox1_DoubleClick(Object sender, System.EventArgs e)
{
    // Get the name of the file to open from the ListBox.
    String file = listBox1.get_SelectedItem().ToString();
    try {
        // Determine if the file exists before loading.
        if (System.IO.File.Exists(file)) {
            // Open the file and use a TextReader to read the contents 
            // into the TextBox.
            System.IO.FileInfo myFile = new System.IO.FileInfo(listBox1.
                get_SelectedItem().ToString());
            System.IO.TextReader myData = myFile.OpenText();
            textBox1.set_Text(myData.ReadToEnd());
            myData.Close();
        }
    }
    // Exception is thrown by the OpenText method of the FileInfo class.
    catch (System.IO.FileNotFoundException exp) {
        MessageBox.Show("The file you specified does not exist.");
    }
    // Exception is thrown by the ReadToEnd method of the TextReader class.
    catch (System.IO.IOException exp) {
        MessageBox.Show("There was a problem loading the file into the "
            + "TextBox. Ensure that the file is a valid text file.");
    }
} //listBox1_DoubleClick

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0에서 지원

참고 항목

참조

Control 클래스
Control 멤버
System.Windows.Forms 네임스페이스
OnDoubleClick
StandardClick
StandardDoubleClick
Control.Click 이벤트
MouseClick
MouseDoubleClick