VisualStyleRenderer.IsElementDefined(VisualStyleElement) Metode
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.
Menentukan apakah elemen gaya visual yang ditentukan ditentukan oleh gaya visual saat ini.
public:
static bool IsElementDefined(System::Windows::Forms::VisualStyles::VisualStyleElement ^ element);
public static bool IsElementDefined (System.Windows.Forms.VisualStyles.VisualStyleElement element);
static member IsElementDefined : System.Windows.Forms.VisualStyles.VisualStyleElement -> bool
Public Shared Function IsElementDefined (element As VisualStyleElement) As Boolean
Parameter
- element
- VisualStyleElement
Yang VisualStyleElement kelas dan kombinasi bagiannya akan diverifikasi.
Mengembalikan
true
jika kombinasi properti ClassName dan Part didefinisikan element
; jika tidak, false
.
Pengecualian
Sistem operasi tidak mendukung gaya visual.
-atau-
Gaya visual dinonaktifkan oleh pengguna dalam sistem operasi.
-atau-
Gaya visual tidak diterapkan ke area klien jendela aplikasi.
Contoh
Contoh kode berikut menunjukkan cara menggunakan IsElementDefined metode untuk menentukan apakah akan menginisialisasi VisualStyleRenderer ke tertentu VisualStyleElement. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk VisualStyleRenderer gambaran umum kelas.
// Set the VisualStyleRenderer to a new element.
private:
bool SetRenderer(VisualStyleElement^ element)
{
if (!VisualStyleRenderer::IsElementDefined(element))
{
return false;
}
if (renderer == nullptr)
{
renderer = gcnew VisualStyleRenderer(element);
}
else
{
renderer->SetParameters(element);
}
return true;
}
// Set the VisualStyleRenderer to a new element.
private bool SetRenderer(VisualStyleElement element)
{
if (!VisualStyleRenderer.IsElementDefined(element))
{
return false;
}
if (renderer == null)
{
renderer = new VisualStyleRenderer(element);
}
else
{
renderer.SetParameters(element);
}
return true;
}
' Set the VisualStyleRenderer to a new element.
Private Function SetRenderer(ByVal element As _
VisualStyleElement) As Boolean
If Not VisualStyleRenderer.IsElementDefined(element) Then
Return False
End If
If renderer Is Nothing Then
renderer = New VisualStyleRenderer(element)
Else
renderer.SetParameters(element)
End If
Return True
End Function
Keterangan
Metode ini memeriksa nilai IsSupported properti secara internal.