方法 : RadioButtonList Web サーバー コントロールにレイアウトを設定する

更新 : 2007 年 11 月

既定では、RadioButtonList Web サーバー コントロールには 1 列のボタンだけが表示されます。ただし、任意の列数を指定したり、列内で項目を縦 (既定値) に表示するか横に表示するかを指定したりできます。3 列の縦のレイアウトは、次のようになります。

A    D    G
B    E    H
C    F

同じ項目の横のレイアウトは、次のようになります。

A    B    C
D    E    F
G    H
y837ez6f.alert_note(ja-jp,VS.90).gifメモ :

個別の RadioButton Web サーバー コントロールを使用している場合は、コントロールのプロパティとしてレイアウトを設定しないでください。その代わりに、単にページ フロー内にオプション ボタンを追加することによって設定します。これらのコントロールの違いの詳細については、「RadioButton Web サーバー コントロールおよび RadioButtonList Web サーバー コントロールの概要」を参照してください。

列数および列の順序を指定するには

  1. RadioButtonList コントロールの RepeatColumns プロパティに必要な列数を設定します。

  2. 次のコード例に示すように、RepeatDirection 列挙型を使用して RepeatDirection プロパティに Vertical または Horizontal を設定します。

    Protected Sub Button1_Click(ByVal sender As Object, _
            ByVal e As System.EventArgs) Handles Button1.Click
       ' Create five radio buttons.
       Dim colors() As String = _
          New String() {"Red", "Blue", "Green", "Yellow", "Orange"}
       RadioButtonList1.Items.Clear()
       Dim i As Integer
       For i = 0 To ubound(colors)
          RadioButtonList1.Items.Add(colors(i))
       Next
       ' Lay out the radio buttons horizontally.
       RadioButtonList1.RepeatDirection = RepeatDirection.Horizontal
    End Sub
    
    protected void Button1_Click (object sender, System.EventArgs e)
    {
       // Create five radio buttons.
       string[] colors = {"Red", "Blue", "Green", "Yellow", "Orange"};
       this.RadioButtonList1.Items.Clear();
       for(int i=0;i < colors.GetLength(0);i++){
          this.RadioButtonList1.Items.Add(colors[i]);
       }   
       // Lay out the radio buttons horizontally.
       this.RadioButtonList1.RepeatDirection = 
           RepeatDirection.Horizontal;
    }
    

参照

参照

RadioButton Web サーバー コントロールおよび RadioButtonList Web サーバー コントロールの概要