CheckBoxRenderer.GetGlyphSize(Graphics, CheckBoxState) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the size of the check box glyph.
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
- state
- CheckBoxState
One of the CheckBoxState values that specifies the visual state of the check box.
A Size that represents the size of the check box glyph.
The following code example uses the GetGlyphSize method to determine the bounds of the check box text. This code example is part of a larger example provided for the CheckBoxRenderer class.
// 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
The size of the check box glyph is determined by the current visual style of the operating system.
Proizvod | Verzije |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
Povratne informacije o proizvodu .NET
.NET je projekt otvorenog koda. Odaberite vezu za slanje povratnih informacija: