Bagikan melalui


LinkLabelLinkClickedEventArgs.Button Properti

Definisi

Mendapatkan tombol mouse yang menyebabkan tautan diklik.

public:
 property System::Windows::Forms::MouseButtons Button { System::Windows::Forms::MouseButtons get(); };
public System.Windows.Forms.MouseButtons Button { get; }
member this.Button : System.Windows.Forms.MouseButtons
Public ReadOnly Property Button As MouseButtons

Nilai Properti

Salah MouseButtons satu nilai.

Contoh

Contoh kode berikut menunjukkan penggunaan anggota ini. Dalam contoh, penanganan aktivitas melaporkan kemunculan LinkLabel.LinkClicked peristiwa. Laporan ini membantu Anda mempelajari kapan peristiwa terjadi dan dapat membantu Anda dalam penelusuran kesalahan. Untuk melaporkan beberapa peristiwa atau peristiwa yang sering terjadi, pertimbangkan untuk mengganti MessageBox.Show dengan Console.WriteLine atau menambahkan pesan ke multibaris TextBox.

Untuk menjalankan kode contoh, tempelkan ke dalam proyek yang berisi instans jenis LinkLabel bernama LinkLabel1. Kemudian pastikan bahwa penanganan aktivitas dikaitkan dengan peristiwa.LinkLabel.LinkClicked

private void LinkLabel1_LinkClicked(Object sender, LinkLabelLinkClickedEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Button", e.Button );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Link", e.Link );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "LinkClicked Event" );
}
Private Sub LinkLabel1_LinkClicked(sender as Object, e as LinkLabelLinkClickedEventArgs) _ 
     Handles LinkLabel1.LinkClicked

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Button", e.Button)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Link", e.Link)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"LinkClicked Event")

End Sub

Berlaku untuk