ListViewItem.Tag プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

[LocalizableAttribute(false)] [BindableAttribute(true)] public: property Object^ Tag { Object^ get (); void set (Object^ value); }
項目に関連付けられている情報を格納するオブジェクト。

Tag プロパティを使用して、項目に関連付けるオブジェクトを格納できます。任意の項目を格納できますが、Tag プロパティは、通常、一意の識別子や項目のデータのデータベースでのインデックス位置など、項目に関する文字列情報を格納するために使用します。

ListViewItem を初期化し、Tag プロパティと Text プロパティを設定する方法を、次のコード例に示します。この例を実行するには、ListView1 という名前の ListView が配置されているフォームに次のコードを貼り付け、フォームのコンストラクタまたは Load のイベント処理メソッドから InitializeListViewItems を呼び出します。
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
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); } }
private: void InitializeListViewItems() { ListView1->View = View::List; array<System::Windows::Forms::Cursor^>^favoriteCursors = {Cursors::Help ,Cursors::Hand,Cursors::No,Cursors::Cross}; // Populate the ListView control with the array of Cursors. System::Collections::IEnumerator^ myEnum = favoriteCursors->GetEnumerator(); while ( myEnum->MoveNext() ) { System::Windows::Forms::Cursor^ aCursor = safe_cast<System::Windows::Forms::Cursor^>(myEnum->Current); // Construct the ListViewItem object ListViewItem^ item = gcnew 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 ); } }
private void InitializeListViewItems() { listView1.set_View(View.List); Cursor favoriteCursors[] = new Cursor[] { Cursors.get_Help() , Cursors.get_Hand(), Cursors.get_No(), Cursors.get_Cross() }; // Populate the ListView control with the array of Cursors. for (int iCtr = 0; iCtr < favoriteCursors.length; iCtr++) { Cursor aCursor = favoriteCursors[iCtr]; // Construct the ListViewItem object ListViewItem item = new ListViewItem(); // Set the Text property to the cursor name. item.set_Text(aCursor.ToString()); // Set the Tag property to the cursor. item.set_Tag(aCursor); // Add the ListViewItem to the ListView. listView1.get_Items().Add(item); } } //InitializeListViewItems

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


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

- ListViewItem.Tag プロパティのページへのリンク