RadioButtonRenderer.GetGlyphSize(Graphics, RadioButtonState) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回選項按鈕 (Option button) (也稱為選項按鈕 (Radio button)) 圖像的大小 (以像素為單位)。
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
備註
這個值是由作業系統的目前視覺化樣式所決定。