[Tips][RadioButton] チェックマークの位置を変更する

スポンサーリンク

RadioButtonコントロールはチェックマークの配置位置を設定することができます。

配置位置の設定はCheckAlignプロパティContentAlignment列挙体のメンバを指定します。

ContentAlignment列挙体
メンバ名 説明
TopLeft 上端左寄せ
TopCenter 上端中央寄せ
TopRight 上端右寄せ
MiddleLeft 中段左寄せ
MiddleCenter 中段中央寄せ
MiddleRight 中段右寄せ
BottomLeft 下段左寄せ
BottomCenter 下段中央寄せ
BottmRight 下段右寄せ

下記は、RadioButtonコントロールのチェックマーク位置を設定する例です。

配置位置をわかりやすくするために、RadioButtonコントロールのAutoSizeをFalseに、背景色をActiveColorに設定しました。

VBの例

' フォームロード時の処理
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    '★★★チェックマークの位置を変更する★★★
    RadioButton1.CheckAlign = ContentAlignment.TopLeft
    RadioButton2.CheckAlign = ContentAlignment.TopCenter
    RadioButton3.CheckAlign = ContentAlignment.TopRight
    RadioButton4.CheckAlign = ContentAlignment.MiddleLeft
    RadioButton5.CheckAlign = ContentAlignment.MiddleCenter
    RadioButton6.CheckAlign = ContentAlignment.MiddleRight
    RadioButton7.CheckAlign = ContentAlignment.BottomLeft
    RadioButton8.CheckAlign = ContentAlignment.BottomCenter
    RadioButton9.CheckAlign = ContentAlignment.BottomRight
End Sub

C#の例

// フォームロード時の処理
private void Form3_Load(object sender, EventArgs e)
{
    // ★★★チェックマークの位置を変更する★★★
    radioButton1.CheckAlign = ContentAlignment.TopLeft;
    radioButton2.CheckAlign = ContentAlignment.TopCenter;
    radioButton3.CheckAlign = ContentAlignment.TopRight;
    radioButton4.CheckAlign = ContentAlignment.MiddleLeft;
    radioButton5.CheckAlign = ContentAlignment.MiddleCenter;
    radioButton6.CheckAlign = ContentAlignment.MiddleRight;
    radioButton7.CheckAlign = ContentAlignment.BottomLeft;
    radioButton8.CheckAlign = ContentAlignment.BottomCenter;
    radioButton9.CheckAlign = ContentAlignment.BottomRight;
}
Please follow and like us:

コメント

タイトルとURLをコピーしました