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

[LocalizableAttribute(true)] public: property String^ Text { String^ get (); void set (String^ value); }
ListItem コントロールによって表される項目のリスト コントロールに表示されるテキスト。既定値は String.Empty です。

Text プロパティを使用して、ListItem によって表される項目のリスト コントロールに表示されるテキストを確認します。
![]() |
---|
Text プロパティに null 参照 (Visual Basic では Nothing) が格納されている場合、get アクセサは Value プロパティの値を返します。さらに、Value プロパティに null 参照 (Visual Basic では Nothing) が格納されている場合は、String.Empty が返されます。 |
このプロパティの値は、設定時に、デザイナ ツールを使用してリソース ファイルに自動的に保存できます。詳細については、LocalizableAttribute、ASP.NET のグローバリゼーションおよびローカリゼーション の各トピックを参照してください。

![]() |
---|
次のコード サンプルはシングルファイル コード モデルを使用しており、分離コード ファイルに直接コピーされた場合は正常に動作しない可能性があります。このコード サンプルは、拡張子が .aspx の空のテキスト ファイルにコピーする必要があります。Web フォームのコード モデルの詳細については、「ASP.NET Web ページのコード モデル」を参照してください。 |
<%@ Page Language="VB" %> <!-- The following example demonstrates adding items to and removing items from ListBox controls. When an item is selected in ListBox1, a new ListBoxItem with the same value can be created and added to ListBox2, if ListBox2 does not already contain an item with that value. When the new ListBoxItem is created, it receives the Value property of the selected item as its Text property, and the Text property of the selected item as its value property. --> <html> <head> <script language="VB" runat="server"> Sub AddBtn_Click(Sender As Object, e As EventArgs) If ListBox1.SelectedIndex > -1 Then If ListBox2.Items.FindByValue(ListBox1.SelectedItem.Text) is Nothing Then Dim Item As ListItem = new ListItem() 'Text and Value are swapped Item.Text = ListBox1.SelectedItem.Value Item.Value = ListBox1.SelectedItem.Text ListBox2.Items.Add(Item) End If End If End Sub Sub DelBtn_Click(Sender As Object, e As EventArgs) If ListBox2.SelectedIndex > -1 Then ListBox2.Items.Remove(ListBox2.SelectedItem) End If End Sub </script> </head> <body> <h3>ListItem Example</h3> <p> <form runat=server> <table> <tr><td> <asp:ListBox id=ListBox1 Width="100px" runat="server"> <asp:ListItem Value="Value 1">Item 1</asp:ListItem> <asp:ListItem Value="Value 2">Item 2</asp:ListItem> <asp:ListItem Value="Value 3">Item 3</asp:ListItem> <asp:ListItem Value="Value 4">Item 4</asp:ListItem> <asp:ListItem Value="Value 5" Selected="True">Item 5</asp:ListItem> <asp:ListItem Value="Value 6">Item 6</asp:ListItem> </asp:ListBox> </td><td> <asp:button Text="--->" OnClick="AddBtn_Click" runat="server" /><br> <asp:button Text="<---" OnClick="DelBtn_Click" runat="server" /> </td><td> <asp:ListBox id=ListBox2 Width="100px" runat="server"/> </td></tr> </table> </form> </body> </html>
<!-- The following example demonstrates adding items to and removing items from ListBox controls. When an item is selected in ListBox1, a new ListBoxItem with the same value can be created and added to ListBox2, if ListBox2 does not already contain an item with that value. When the new ListBoxItem is created, it receives the Value property of the selected item as its Text property, and the Text property of the selected item as its value property. --> <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script runat="server"> void AddBtn_Click(Object Sender, EventArgs e) { if (ListBox1.SelectedIndex > -1) { if (ListBox2.Items.FindByValue(ListBox1.SelectedItem.Text) == null) { ListItem Item = new ListItem(); // Text and Value are swapped. Item.Text = ListBox1.SelectedItem.Value; Item.Value = ListBox1.SelectedItem.Text; ListBox2.Items.Add(Item); } } } void DelBtn_Click(Object Sender, EventArgs e) { if (ListBox2.SelectedIndex > -1) { ListBox2.Items.Remove(ListBox2.SelectedItem); } } </script> </head> <body> <h3>ListItem Example</h3> <p> <form runat=server> <table> <tr><td> <asp:ListBox id=ListBox1 Width="100px" runat="server"> <asp:ListItem Value="Value 1">Item 1</asp:ListItem> <asp:ListItem Value="Value 2">Item 2</asp:ListItem> <asp:ListItem Value="Value 3">Item 3</asp:ListItem> <asp:ListItem Value="Value 4">Item 4</asp:ListItem> <asp:ListItem Value="Value 5" Selected="True">Item 5</asp:ListItem> <asp:ListItem Value="Value 6">Item 6</asp:ListItem> </asp:ListBox> </td><td> <asp:button Text="--->" OnClick="AddBtn_Click" runat="server" /><br> <asp:button Text="<---" OnClick="DelBtn_Click" runat="server" /> </td><td> <asp:ListBox id=ListBox2 Width="100px" runat="server"/> </td></tr> </table> </form> </body> </html>
<!-- The following example demonstrates adding items to and removing items from ListBox controls. When an item is selected in ListBox1, a new ListBoxItem with the same value can be created and added to ListBox2, if ListBox2 does not already contain an item with that value. When the new ListBoxItem is created, it receives the Value property of the selected item as its Text property, and the Text property of the selected item as its value property. --> <%@ Page Language="JScript" %> <html> <head> <script language="JScript" runat="server"> function AddBtn_Click(Sender : Object, e : EventArgs) { if (ListBox1.SelectedIndex > -1) { if (ListBox2.Items.FindByValue(ListBox1.SelectedItem.Text)==null) { var Item : ListItem = new ListItem(); // Text and Value are swapped. Item.Text = ListBox1.SelectedItem.Value; Item.Value = ListBox1.SelectedItem.Text; ListBox2.Items.Add(Item); } } } function DelBtn_Click(Sender : Object, e : EventArgs) { if (ListBox2.SelectedIndex > -1) { ListBox2.Items.Remove(ListBox2.SelectedItem); } } </script> </head> <body> <h3>ListItem Example</h3> <p> <form runat=server> <table> <tr><td> <asp:ListBox id=ListBox1 Width="100px" runat="server"> <asp:ListItem Value="Value 1">Item 1</asp:ListItem> <asp:ListItem Value="Value 2">Item 2</asp:ListItem> <asp:ListItem Value="Value 3">Item 3</asp:ListItem> <asp:ListItem Value="Value 4">Item 4</asp:ListItem> <asp:ListItem Value="Value 5" Selected="True">Item 5</asp:ListItem> <asp:ListItem Value="Value 6">Item 6</asp:ListItem> </asp:ListBox> </td><td> <asp:button Text="--->" OnClick="AddBtn_Click" runat="server" /><br> <asp:button Text="<---" OnClick="DelBtn_Click" runat="server" /> </td><td> <asp:ListBox id=ListBox2 Width="100px" runat="server"/> </td></tr> </table> </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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ListItem クラス
ListItem メンバ
System.Web.UI.WebControls 名前空間
Value
ListControl クラス
RadioButtonList
ListBox クラス
DropDownList クラス
CheckBoxList クラス
その他の技術情報
ListBox Web サーバー コントロール
RadioButton Web サーバー コントロールおよび RadioButtonList Web サーバー コントロールの概要
CheckBox Web サーバー コントロールおよび CheckBoxList Web サーバー コントロール
BulletedList Web サーバー コントロール
DropDownList Web サーバー コントロール
Weblioに収録されているすべての辞書からListItem.Text プロパティを検索する場合は、下記のリンクをクリックしてください。

- ListItem.Text プロパティのページへのリンク