RadioButtonRenderer.GetGlyphSize(Graphics, RadioButtonState) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回选项按钮(也称为单选按钮)标志符号的大小(以像素为单位)。
public:
static System::Drawing::Size GetGlyphSize(System::Drawing::Graphics ^ g, System::Windows::Forms::VisualStyles::RadioButtonState state);
public static System.Drawing.Size GetGlyphSize (System.Drawing.Graphics g, System.Windows.Forms.VisualStyles.RadioButtonState state);
static member GetGlyphSize : System.Drawing.Graphics * System.Windows.Forms.VisualStyles.RadioButtonState -> System.Drawing.Size
Public Shared Function GetGlyphSize (g As Graphics, state As RadioButtonState) As Size
参数
- state
- RadioButtonState
RadioButtonState 值之一,它指定选项按钮的可视状态。
返回
表示选项按钮标志符号的大小(以像素为单位)的 Size。
示例
下面的代码示例使用 GetGlyphSize 该方法来确定选项按钮文本的边界。 此代码示例是为类提供的大型示例的 RadioButtonRenderer 一部分。
// Define the text bounds so that the text rectangle
// does not include the radio button.
public:
property Rectangle TextRectangle
{
Rectangle get()
{
Graphics^ g = this->CreateGraphics();
textRectangleValue.X = ClientRectangle.X +
RadioButtonRenderer::GetGlyphSize(g,
RadioButtonState::UncheckedNormal).Width;
textRectangleValue.Y = ClientRectangle.Y;
textRectangleValue.Width = ClientRectangle.Width -
RadioButtonRenderer::GetGlyphSize(g,
RadioButtonState::UncheckedNormal).Width;
textRectangleValue.Height = ClientRectangle.Height;
delete g;
return textRectangleValue;
}
}
// Define the text bounds so that the text rectangle
// does not include the radio button.
public Rectangle TextRectangle
{
get
{
using (Graphics g = this.CreateGraphics())
{
textRectangleValue.X = ClientRectangle.X +
RadioButtonRenderer.GetGlyphSize(g,
RadioButtonState.UncheckedNormal).Width;
textRectangleValue.Y = ClientRectangle.Y;
textRectangleValue.Width = ClientRectangle.Width -
RadioButtonRenderer.GetGlyphSize(g,
RadioButtonState.UncheckedNormal).Width;
textRectangleValue.Height = ClientRectangle.Height;
}
return textRectangleValue;
}
}
' Define the text bounds so that the text rectangle
' does not include the radio button.
Public ReadOnly Property TextRectangle() As Rectangle
Get
Using g As Graphics = Me.CreateGraphics()
With textRectangleValue
.X = Me.ClientRectangle.X + _
RadioButtonRenderer.GetGlyphSize(g, _
RadioButtonState.UncheckedNormal).Width
.Y = Me.ClientRectangle.Y
.Width = Me.ClientRectangle.Width - _
RadioButtonRenderer.GetGlyphSize(g, _
RadioButtonState.UncheckedNormal).Width
.Height = Me.ClientRectangle.Height
End With
End Using
Return textRectangleValue
End Get
End Property
注解
此值由操作系统的当前视觉样式确定。