Control.DoubleClick Olay
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
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 DoubleClick metin dosyalarını bir ListBox denetime yüklemek için olayını ListBox kullanırTextBox.
// 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ı, iki tıklama yerine çift tıklama olarak kabul edilmesi gereken bir fare düğmesinin 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 DoubleClick olayları tetiklenir ve her iki yöntem de çağrılır. Bir denetime çift tıklanırsa ve bu denetim olayı desteklemiyorsa DoubleClick , Click olay iki kez tetiklenebilir.
Bu olayın yükseltilmesi için ve StandardDoubleClick değerlerini StandardClickControlStyles olarak ayarlamanız true gerekir. Mevcut Windows Forms denetimlerinden devralıyorsanız bu değerler zaten true olarak ayarlanmış olabilir.
Note
Koleksiyonda en az bir TabControl tane olmadığı sürece sınıfı için TabPage aşağıdaki olaylar tetiklenmez: TabControl.TabPages, ClickDoubleClick, , MouseDown, MouseUp, MouseHoverve MouseEnterMouseLeave.MouseMove Koleksiyonda en az bir tane TabPage varsa ve kullanıcı sekme denetiminin üst bilgisi (adların TabPage göründüğü 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 StandardClickStandardDoubleClick veya ControlStyles değerlerini true olarak değiştirmek beklenmeyen davranışlara neden olabilir veya denetim Click veya DoubleClick olaylarını desteklemiyorsa 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.
| Kontrol | Sol Fare Tıklaması | Sol Fare çift tıklaması | Sağ Fare Tıklaması | Sağ Fare çift tıklaması | Orta Fare Tıklaması | Orta Fare Çift Tıklaması | XButton1 Fare Tıklaması | XButton1 Fare Double-Click | XButton2 Fare Tıklaması | XButton2 Fare Double-Click |
|---|---|---|---|---|---|---|---|---|---|---|
| MonthCalendar | yok | yok | yok | yok | yok | yok | yok | yok | yok | yok |
| Button | Buna tıklayın | Tıklayın, Tıklayın | yok | yok | yok | yok | yok | yok | yok | yok |
| ListBox | Buna tıklayın | Tıklayın, Çift Tıklayın | yok | yok | yok | yok | yok | yok | yok | yok |
| TextBox | Buna tıklayın | Tıklayın, Çift Tıklayın | yok | yok | yok | yok | yok | yok | yok | yok |
|
*
TreeView, * ListView | Buna tıklayın | Tıklayın, Çift Tıklayın | 'e tıklayın | Tıklayın, Çift Tıklayın | yok | yok | yok | yok | yok | yok |
| ProgressBar | Buna tıklayın | Tıklayın, Tıklayın | 'e tıklayın | Tıklayın, Tıklayın | 'e tıklayın | Tıklayın, Tıklayın | 'e tıklayın | Tıklayın, Tıklayın | 'e tıklayın | Tıklayın, Tıklayın |
|
Form
** TabControl | Buna tıklayın | Tıklayın, Çift Tıklayın | 'e tıklayın | Tıklayın, Çift Tıklayın | 'e tıklayın | Tıklayın, Çift Tıklayın | 'e tıklayın | Tıklayın, Çift Tıklayın | 'e tıklayın | Tıklayın, Çift Tıklayın |
* Fare işaretçisi bir alt nesnenin (TreeNode veya ListViewItem) üzerinde olmalıdır.
** Koleksiyonunda TabControlTabPage en az bir tane TabPages olmalıdır.