CheckBoxRenderer.GetGlyphSize(Graphics, CheckBoxState) Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Vrátí velikost zaškrtávacího políčka glyf.
public:
static System::Drawing::Size GetGlyphSize(System::Drawing::Graphics ^ g, System::Windows::Forms::VisualStyles::CheckBoxState state);
public static System.Drawing.Size GetGlyphSize (System.Drawing.Graphics g, System.Windows.Forms.VisualStyles.CheckBoxState state);
static member GetGlyphSize : System.Drawing.Graphics * System.Windows.Forms.VisualStyles.CheckBoxState -> System.Drawing.Size
Public Shared Function GetGlyphSize (g As Graphics, state As CheckBoxState) As Size
Parametry
- state
- CheckBoxState
Jedna z CheckBoxState hodnot, které určují stav vizuálu zaškrtávacího políčka.
Návraty
A Size , který představuje velikost zaškrtávacího políčka glyf.
Příklady
Následující příklad kódu používá metodu GetGlyphSize k určení hranic textu zaškrtávacího políčka. Tento příklad kódu je součástí většího příkladu zadaného CheckBoxRenderer pro třídu.
// Calculate the text bounds, exluding the check box.
Rectangle getTextRectangle()
{
Graphics ^g = this->CreateGraphics();
textRectangleValue.X = ClientRectangle.X +
CheckBoxRenderer::GetGlyphSize(g,
CheckBoxState::UncheckedNormal).Width;
textRectangleValue.Y = ClientRectangle.Y;
textRectangleValue.Width = ClientRectangle.Width -
CheckBoxRenderer::GetGlyphSize(g,
CheckBoxState::UncheckedNormal).Width;
textRectangleValue.Height = ClientRectangle.Height;
delete g;
return textRectangleValue;
}
// Calculate the text bounds, exluding the check box.
public Rectangle TextRectangle
{
get
{
using (Graphics g = this.CreateGraphics())
{
textRectangleValue.X = ClientRectangle.X +
CheckBoxRenderer.GetGlyphSize(g,
CheckBoxState.UncheckedNormal).Width;
textRectangleValue.Y = ClientRectangle.Y;
textRectangleValue.Width = ClientRectangle.Width -
CheckBoxRenderer.GetGlyphSize(g,
CheckBoxState.UncheckedNormal).Width;
textRectangleValue.Height = ClientRectangle.Height;
}
return textRectangleValue;
}
}
' Calculate the text bounds, exluding the check box.
Public ReadOnly Property TextRectangle() As Rectangle
Get
Using g As Graphics = Me.CreateGraphics()
With textRectangleValue
.X = Me.ClientRectangle.X + _
CheckBoxRenderer.GetGlyphSize(g, _
CheckBoxState.UncheckedNormal).Width
.Y = Me.ClientRectangle.Y
.Width = Me.ClientRectangle.Width - _
CheckBoxRenderer.GetGlyphSize(g, _
CheckBoxState.UncheckedNormal).Width
.Height = Me.ClientRectangle.Height
End With
End Using
Return textRectangleValue
End Get
End Property
Poznámky
Velikost glyfu zaškrtávacího políčka je určena aktuálním vizuálním stylem operačního systému.