Control.DoubleClick 이벤트

정의

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

public:
 event EventHandler ^ DoubleClick;
public event EventHandler DoubleClick;
public event EventHandler? DoubleClick;
member this.DoubleClick : EventHandler 
Public Custom Event DoubleClick As EventHandler 

이벤트 유형

EventHandler

예제

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

   // 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.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 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

설명

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

이 이벤트를 발생하려면 true 이 이벤트의 값과 StandardClick 값을 ControlStyles 설정 StandardDoubleClick 해야 합니다. 이러한 값은 기존 Windows Forms 컨트롤에서 상속하는 경우 이미 설정 true 되었을 수 있습니다.

참고

컬렉션 DoubleClickMouseUpMouseLeave MouseDownMouseHoverMouseEnterMouseMoveClick에 하나 이상의 TabControl.TabPages TabPage 이벤트가 없는 한 클래스에 TabControl 대해 다음 이벤트가 발생하지 않습니다. 컬렉션에 하나 TabPage 이상이 있고 사용자가 탭 컨트롤의 머리글(이름이 표시되는 위치 TabPage ) TabControl 과 상호 작용하는 경우 적절한 이벤트가 발생합니다. 그러나 사용자 상호 작용이 탭 페이지의 TabPage 클라이언트 영역 내에 있는 경우 적절한 이벤트가 발생합니다.

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

상속자 참고

표준 Windows Forms 컨트롤에서 상속하고 값을 변경 StandardClick StandardDoubleClick ControlStyles 하면 true 예기치 않은 동작이 발생하거나 컨트롤이 해당 또는 DoubleClick 이벤트를 지원하지 Click 않는 경우 전혀 영향을 주지 않을 수 있습니다.

다음 표에서는 지정된 마우스 동작에 대한 응답으로 발생하는 Windows Forms 컨트롤 및 이벤트(Click또는DoubleClick)를 나열합니다.

제어 마우스 왼쪽 클릭 마우스 왼쪽 두 번 클릭 마우스 오른쪽 단추 클릭 마우스 오른쪽 단추로 두 번 클릭 마우스 가운데 클릭 마우스 가운데 두 번 클릭 XButton1 마우스 클릭 XButton1 마우스 Double-Click XButton2 마우스 클릭 XButton2 마우스 Double-Click
MonthCalendar, DateTimePicker, RichTextBox, HScrollBar, VScrollBar 없음 없음 없음 없음 없음 없음 없음 없음 없음 없음
Button, CheckBox, RadioButton 클릭 클릭, 클릭 없음 없음 없음 없음 없음 없음 없음 없음
ListBox, CheckedListBox, ComboBox 클릭 클릭, DoubleClick 없음 없음 없음 없음 없음 없음 없음 없음
TextBox, DomainUpDown, NumericUpDown 클릭 클릭, DoubleClick 없음 없음 없음 없음 없음 없음 없음 없음
* TreeView, \* ListView 클릭 클릭, 더블클릭 클릭 클릭, 더블클릭 없음 없음 없음 없음 없음 없음
ProgressBar, TrackBar 클릭 클릭, 클릭 클릭 클릭, 클릭 클릭 클릭, 클릭 클릭 클릭, 클릭 클릭 클릭, 클릭
Form, DataGrid, Label, LinkLabel, Panel, GroupBox, PictureBox, Splitter, StatusBar, ToolBar, TabPage, ** TabControl 클릭 클릭, 더블클릭 클릭 클릭, 더블클릭 클릭 클릭, 더블클릭 클릭 클릭, 더블클릭 클릭 클릭, 더블클릭

* 마우스 포인터는 자식 개체(TreeNode 또는 ListViewItem) 위에 있어야 합니다.

TabControl** 컬렉션에 TabPages 하나 TabPage 이상이 있어야 합니다.

적용 대상

추가 정보