Bagikan melalui


ToolStripDropDown.AutoClose Properti

Definisi

Mendapatkan atau menetapkan nilai yang menunjukkan apakah ToolStripDropDown kontrol harus ditutup secara otomatis ketika kehilangan aktivasi.

public:
 property bool AutoClose { bool get(); void set(bool value); };
public bool AutoClose { get; set; }
member this.AutoClose : bool with get, set
Public Property AutoClose As Boolean

Nilai Properti

trueToolStripDropDown jika kontrol secara otomatis ditutup; jika tidak, false. Default adalah true.

Contoh

Contoh kode berikut menunjukkan cara mengalihkan nilai AutoClose properti sebagai respons terhadap pilihan kotak centang.

// This method toggles the value of the ToolStripDropDown 
// control's AutoClose property.
private void autoCloseCheckBox_CheckedChanged(object sender, EventArgs e)
{   
    this.contextMenuStrip1.AutoClose ^= true;
}
' This method toggles the value of the ToolStripDropDown 
' control's AutoClose property.
Private Sub autoCloseCheckBox_CheckedChanged(sender As Object, e As EventArgs) Handles autoCloseCheckBox.CheckedChanged
   Me.contextMenuStrip1.AutoClose = Me.contextMenuStrip1.AutoClose Xor True
 End Sub

Keterangan

Jika Anda ingin ToolStripDropDown yang selalu tetap terbuka, atur AutoClose ke false.

Catatan

Pertimbangkan untuk menangani Closing peristiwa alih-alih mengatur AutoClose properti . CloseReason Periksa bidang di handler Anda Closing untuk menentukan logika penutupan kustom.

Berlaku untuk