項目のテキストを取得または設定します。
Public Property Text As String
[C#]
public string Text {get; set;}
[C++]
public: __property String* get_Text();public: __property void set_Text(String*);
[JScript]
public function get Text() : String;public function set Text(String);
プロパティ値
項目を示すために表示するテキスト。
解説
Text プロパティを使用すると、項目に対して表示されるテキストを変更できます。 BackColor 、 ForeColor 、 Font の各プロパティを使用して、テキストの表示方法を指定できます。 ListView クラスには、テキストを次の行に折り返すか、または 1 行に表示するかを決定する LabelWrap プロパティが用意されています。
使用例
Tag プロパティと Text プロパティを設定して ListViewItems を初期化する例を次に示します。この例を実行するには、ListView1 という名前の ListView が配置されているフォームに、次のコードを配置して、フォームのコンストラクタまたは Load メソッドから InitializeListViewItems メソッドを呼び出します。
[SampleID='System.Windows.Forms.ListViewItemExample' SnippetID='1']
--------- Languages displayed= cs, vb ---------
--------- cs ---------
--------- Snippet 1 ---------
private void InitializeListViewItems()
{
ListView1.View = View.List;
Cursor[] favoriteCursors = new Cursor[]{Cursors.Help,
Cursors.Hand, Cursors.No, Cursors.Cross};
// Populate the ListView control with the array of Cursors.
foreach ( Cursor aCursor in favoriteCursors )
{
// Construct the ListViewItem object
ListViewItem item = new ListViewItem();
// Set the Text property to the cursor name.
item.Text = aCursor.ToString();
// Set the Tag property to the cursor.
item.Tag = aCursor;
// Add the ListViewItem to the ListView.
ListView1.Items.Add(item);
}
}
--------- vb ---------
--------- Snippet 1 ---------
Private Sub InitializeListViewItems()
ListView1.View = View.List
Dim aCursor As Cursor
Dim favoriteCursors() As Cursor = New Cursor() _
{Cursors.Help, Cursors.Hand, Cursors.No, Cursors.Cross}
' Populate the ListView control with the array of Cursors.
For Each aCursor In favoriteCursors
' Construct the ListViewItem object
Dim item As New ListViewItem
' Set the Text property to the cursor name.
item.Text = aCursor.ToString
' Set the Tag property to the cursor.
item.Tag = aCursor
' Add the ListViewItem to the ListView.
ListView1.Items.Add(item)
Next
End Sub
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
ListViewItem クラス | ListViewItem メンバ | System.Windows.Forms 名前空間 | BackColor | ForeColor | Font | ListView.LabelWrap