다음을 통해 공유


방법: RadioButtonList 웹 서버 컨트롤의 레이아웃 설정

업데이트: 2007년 11월

기본적으로 RadioButtonList 웹 서버 컨트롤에는 하나의 단추 열이 표시됩니다. 그러나 열의 개수를 지정할 수 있으며 지정한 열 내에서 세로(기본값) 또는 가로로 항목 정렬 방법을 지정할 수 있습니다. 세 열의 세로 레이아웃은 다음과 같습니다.

A    D    G
B    E    H
C    F

같은 항목에 대한 가로 레이아웃은 다음과 같습니다.

A    B    C
D    E    F
G    H
참고:

개별 RadioButton 웹 서버 컨트롤을 사용하는 경우에는 레이아웃을 컨트롤의 속성으로 설정하지 않습니다. 대신 라디오 단추를 페이지 흐름에 추가하여 레이아웃을 간단히 설정할 수 있습니다. 이러한 컨트롤 간의 차이에 대한 자세한 내용은 RadioButton 및 RadioButtonList 웹 서버 컨트롤 개요를 참조하십시오.

열 수 및 정렬 방식을 지정하려면

  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 및 RadioButtonList 웹 서버 컨트롤 개요