ToolStripItemEventArgs.Item Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
ToolStripItem Mendapatkan yang untuk menangani peristiwa.
public:
property System::Windows::Forms::ToolStripItem ^ Item { System::Windows::Forms::ToolStripItem ^ get(); };
public System.Windows.Forms.ToolStripItem Item { get; }
public System.Windows.Forms.ToolStripItem? Item { get; }
member this.Item : System.Windows.Forms.ToolStripItem
Public ReadOnly Property Item As ToolStripItem
Nilai Properti
yang ToolStripItem akan menangani peristiwa.
Contoh
Contoh kode berikut menunjukkan penggunaan anggota ini. Dalam contoh, penanganan aktivitas melaporkan kemunculan ToolStrip.ItemAdded 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 ToolStrip bernama ToolStrip1
. Kemudian pastikan bahwa penanganan aktivitas dikaitkan dengan peristiwa.ToolStrip.ItemAdded
private void ToolStrip1_ItemAdded(Object sender, ToolStripItemEventArgs e) {
System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Item", e.Item );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "ItemAdded Event" );
}
Private Sub ToolStrip1_ItemAdded(sender as Object, e as ToolStripItemEventArgs) _
Handles ToolStrip1.ItemAdded
Dim messageBoxVB as New System.Text.StringBuilder()
messageBoxVB.AppendFormat("{0} = {1}", "Item", e.Item)
messageBoxVB.AppendLine()
MessageBox.Show(messageBoxVB.ToString(),"ItemAdded Event")
End Sub