ListBox.Rows プロパティ
アセンブリ: System.Web (system.web.dll 内)

ListBox コントロールに表示する行数。既定値は 4 です。



Rows プロパティを使用して、ListBox コントロールに 6 行表示する方法を次の例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script language="VB" runat="server"> Sub SubmitBtn_Click(sender As Object, e As EventArgs) If ListBox1.SelectedIndex > -1 Then Label1.Text = "You chose: " & ListBox1.SelectedItem.Text End If End Sub </script> </head> <body> <h3>ListBox Example</h3> <form runat=server> <asp:ListBox id="ListBox1" Rows="6" Width="100px" SelectionMode="Single" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> <asp:ListItem>Item 5</asp:ListItem> <asp:ListItem>Item 6</asp:ListItem> </asp:ListBox> <asp:button id="Button1" Text="Submit" OnClick="SubmitBtn_Click" runat="server" /> <asp:Label id="Label1" Font-Name="Verdana" Font-Size="10pt" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script language="C#" runat="server"> void SubmitBtn_Click(Object sender, EventArgs e) { if (ListBox1.SelectedIndex > -1) Label1.Text="You chose: " + ListBox1.SelectedItem.Text; } </script> </head> <body> <h3>ListBox Example</h3> <form runat=server> <asp:ListBox id="ListBox1" Rows="6" Width="100px" SelectionMode="Single" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> <asp:ListItem>Item 5</asp:ListItem> <asp:ListItem>Item 6</asp:ListItem> </asp:ListBox> <asp:button id="Button1" Text="Submit" OnClick="SubmitBtn_Click" runat="server" /> <asp:Label id="Label1" Font-Name="Verdana" Font-Size="10pt" runat="server"/> </form> </body> </html>
<%@ Page Language="JScript" AutoEventWireup="True" %> <html> <head> <script language="JSCRIPT" runat="server"> function SubmitBtn_Click(sender : Object, e : EventArgs) { if(ListBox1.SelectedIndex > -1){ Label1.Text = "You chose: " + ListBox1.SelectedItem.Text } } </script> </head> <body> <h3>ListBox Example</h3> <form runat=server> <asp:ListBox id="ListBox1" Rows="6" Width="100px" SelectionMode="Single" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> <asp:ListItem>Item 5</asp:ListItem> <asp:ListItem>Item 6</asp:ListItem> </asp:ListBox> <asp:button id="Button1" Text="Submit" OnClick="SubmitBtn_Click" runat="server" /> <asp:Label id="Label1" Font-Name="Verdana" Font-Size="10pt" runat="server"/> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からListBox.Rows プロパティを検索する場合は、下記のリンクをクリックしてください。

- ListBox.Rows プロパティのページへのリンク