Control.DoubleClick Olay

Tanım

Denetime çift tıklandığında gerçekleşir.

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

Olay Türü

Örnekler

Aşağıdaki kod örneği, içinde listelenen ListBox metin dosyalarını bir TextBox denetime yüklemek için olayını ListBox kullanırDoubleClick.

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

Açıklamalar

Çift tıklama, kullanıcının işletim sisteminin fare ayarları tarafından belirlenir. Kullanıcı, fare düğmesinin iki tıklama yerine çift tıklama olarak kabul edilmesi gereken tıklamaları arasındaki süreyi ayarlayabilir. Bir Click denetime çift tıklandığında olay tetikleniyor. Örneğin, ve olayları için ClickDoubleClick olay FormClick işleyicileriniz varsa, forma çift tıklandığında ve her iki yöntem de çağrıldığında ve DoubleClick olayları tetiklenir. Bir denetime çift tıklanırsa ve bu denetim olayı desteklemiyorsa DoubleClick , Click olay iki kez tetiklenebilir.

Bu olayın tetiklenecek olması için ve StandardClick değerlerini ControlStylestrue olarak ayarlamanız StandardDoubleClick gerekir. Mevcut Windows Forms denetimlerinden devralıyorsanız bu değerler zaten olarak ayarlanmış true olabilir.

Not

Koleksiyonda TabControl.TabPages en az bir olay TabPage olmadığı sürece sınıfı için TabControl aşağıdaki olaylar tetiklenmez: Click, DoubleClick, MouseDown, MouseUp, MouseHover, , MouseEnterMouseLeave ve MouseMove. Koleksiyonda en az bir tane TabPage varsa ve kullanıcı sekme denetiminin üst bilgisi (adların TabPage görüntülendiği yer) ile etkileşime geçtiğinde TabControl uygun olayı tetikler. Ancak, kullanıcı etkileşimi sekme sayfasının istemci alanındaysa, TabPage uygun olayı tetikler.

Olayları işleme hakkında daha fazla bilgi için bkz. Olayları İşleme ve Oluşturma.

Devralanlara Notlar

Standart bir Windows Forms denetiminden devralma ve veya değerlerinin ControlStyles değiştirilmesi StandardClick beklenmeyen davranışlara true neden olabilir veya denetim veya DoubleClick olaylarını desteklemiyorsa ClickStandardDoubleClick hiçbir etkisi olmaz.

Aşağıdaki tabloda, Windows Forms denetimleri ve belirtilen fare eylemine yanıt olarak hangi olayın (Click veya DoubleClick) tetiklendiği listelenir.

Denetim Sol Fare Tıklaması Sol Fare Çift Tıklama Sağ Fare Tıklaması Sağ Fare Çift Tıklama Orta Fare Tıklaması Orta Fare Çift Tıklama XButton1 Fare Tıklaması XButton1 Fare Double-Click XButton2 Fare Tıklaması XButton2 Fare Double-Click
MonthCalendar,

DateTimePicker,

RichTextBox,

HScrollBar,

VScrollBar

yok yok yok yok yok yok yok yok yok yok
Button,

CheckBox,

RadioButton

Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, Tıklayın yok yok yok yok yok yok yok yok
ListBox,

CheckedListBox,

ComboBox

Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, DoubleClick yok yok yok yok yok yok yok yok
TextBox,

DomainUpDown,

NumericUpDown

Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, DoubleClick yok yok yok yok yok yok yok yok
* TreeView,

* ListView

Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, DoubleClick Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, DoubleClick yok yok yok yok yok yok
ProgressBar,

TrackBar

Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, Tıklayın Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, Tıklayın Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, Tıklayın Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, Tıklayın Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, Tıklayın
Form,

DataGrid,

Label,

LinkLabel,

Panel,

GroupBox,

PictureBox,

Splitter,

StatusBar,

ToolBar,

TabPage,

** TabControl

Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, DoubleClick Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, DoubleClick Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, DoubleClick Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, DoubleClick Eski kimlik doğrulamasını engelleme hakkında daha fazla bilgi edinmek için Tıklayın, DoubleClick

* Fare işaretçisi bir alt nesnenin (TreeNode veya ListViewItem) üzerinde olmalıdır.

** Koleksiyonunda TabControlTabPages en az bir tane TabPage olmalıdır.

Şunlara uygulanır

Ayrıca bkz.