@634

ASP.NET - WEBフォームコントロール - asp:CheckBoxList

Advertisement

用途

asp:CheckBoxListコントロールを使用すると、チェックボックスの集合を一度に定義することができる。

書式

<asp:CheckBoxList
    id="CheckBoxList01"
    TextAlign="テキスト位置"
    RepeatLayout="レイアウト"
    RepeatColumns="列数"
    RepeatDirection="整列方向"
    runat="server">
    <asp:ListItem Value="値">テキスト</asp:ListItem>
</asp:CheckBoxList>
※上記の属性以外にも、見栄えの定義などの属性があります。

入れ子になっているasp:ListItemが実際のチェックボックスになる。

TextAlign
RightまたはLeftのどちらかを指定。Rightの場合、チェックボックスの右側に文字列が表示され、Leftの場合はチェックボックスの左側に文字列が表示される。

RepeatLayout
TableかFlowを指定する。Tableを指定すると<table>タグを使用したコードが出力される。Flowの場合はspanタグを使用したコードが出力される。

RepeatColumns
列数を指定する。これにより、n列m行のグループを作成できるので柔軟なレイアウトを行うことができる。

RepeatDirection
HorizontalかVerticalのどちらかを指定する。Horizontalを指定するとチェックボックス群の整列される方向が横になり、Verticalの場合は縦になる。

サンプル

サンプルコード
<form runat="server">
<asp:CheckBoxList
    id="CheckBoxList01"
    TextAlign="Right"
    RepeatLayout="Flow"
    RepeatColumns="2"
    RepeatDirection="Horizontal"
    runat="server">
      <asp:ListItem Value="少年">少年</asp:ListItem>
      <asp:ListItem Value="中年">中年</asp:ListItem>
      <asp:ListItem Value="老人">老人</asp:ListItem>
      <asp:ListItem Value="その他">その他</asp:ListItem>
</asp:CheckBoxList>
</form>

実行イメージ


イベント

SelectedIndexChanged

Advertisement

ショートカット

634
634ブログ
このカテゴリのトップページに戻る
Incubator(Pukiwiki)
634ラボ
   UIコレクションギャラリー
   ZO-3ジェネレーター

サイト検索


Y!ログール