ListViewGroup コンストラクタ (String, HorizontalAlignment)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim header As String Dim headerAlignment As HorizontalAlignment Dim instance As New ListViewGroup(header, headerAlignment)

詳細ビューのサブ項目の値を使って ListView 項目を整理するアプリケーションで、ListViewGroup コンストラクタを使用する方法を次のコード例に示します。この形式のグループ化は、Windows エクスプローラで使用されているグループ化と似ています。この例では、グループが動的に作成されます。各サブ項目列では、一意のサブ項目値ごとに 1 つのグループが作成されます。親項目列では、一意の先頭の文字ごとに 1 つのグループが作成されます。各列について作成されたグループは、サブ項目のテキストまたは先頭の文字と共にハッシュ テーブルに格納されます。列ヘッダーがクリックされると、このテキスト値を使用して項目が適合する列のグループを決定します。
コード全体については、ListViewGroup の概要のリファレンス トピックを参照してください。
' Creates a Hashtable object with one entry for each unique ' subitem value (or initial letter for the parent item) ' in the specified column. Private Function CreateGroupsTable(column As Integer) As Hashtable ' Create a Hashtable object. Dim groups As New Hashtable() ' Iterate through the items in myListView. Dim item As ListViewItem For Each item In myListView.Items ' Retrieve the text value for the column. Dim subItemText As String = item.SubItems(column).Text ' Use the initial letter instead if it is the first column. If column = 0 Then subItemText = subItemText.Substring(0, 1) End If ' If the groups table does not already contain a group ' for the subItemText value, add a new group using the ' subItemText value for the group header and Hashtable key. If Not groups.Contains(subItemText) Then groups.Add( subItemText, New ListViewGroup(subItemText, _ HorizontalAlignment.Left) ) End If Next item ' Return the Hashtable object. Return groups End Function 'CreateGroupsTable
// Creates a Hashtable object with one entry for each unique // subitem value (or initial letter for the parent item) // in the specified column. private Hashtable CreateGroupsTable(int column) { // Create a Hashtable object. Hashtable groups = new Hashtable(); // Iterate through the items in myListView. foreach (ListViewItem item in myListView.Items) { // Retrieve the text value for the column. string subItemText = item.SubItems[column].Text; // Use the initial letter instead if it is the first column. if (column == 0) { subItemText = subItemText.Substring(0, 1); } // If the groups table does not already contain a group // for the subItemText value, add a new group using the // subItemText value for the group header and Hashtable key. if (!groups.Contains(subItemText)) { groups.Add( subItemText, new ListViewGroup(subItemText, HorizontalAlignment.Left) ); } } // Return the Hashtable object. return groups; }
// Creates a Hashtable object with one entry for each unique // subitem value (or initial letter for the parent item) // in the specified column. private: Hashtable^ CreateGroupsTable(int column) { // Create a Hashtable object. Hashtable^ groups = gcnew Hashtable(); // Iterate through the items in myListView. IEnumerator^ myEnum1 = myListView->Items->GetEnumerator(); while (myEnum1->MoveNext()) { ListViewItem^ item = safe_cast<ListViewItem^>(myEnum1->Current); // Retrieve the text value for the column. String^ subItemText = item->SubItems[column]->Text; // Use the initial letter instead if it is the first column. if (column == 0) { subItemText = subItemText->Substring(0, 1); } // If the groups table does not already contain a group // for the subItemText value, add a new group using the // subItemText value for the group header and Hashtable key. if (!groups->Contains(subItemText)) { groups->Add( subItemText, gcnew ListViewGroup(subItemText, HorizontalAlignment::Left) ); } } // Return the Hashtable object. return groups; }
// Creates a Hashtable object with one entry for each unique // subitem value (or initial letter for the parent item) // in the specified column. private Hashtable CreateGroupsTable(int column) { // Create a Hashtable object. Hashtable groups = new Hashtable(); // Iterate through the items in myListView. for (int iCtr = 0; iCtr < myListView.get_Items().get_Count(); iCtr++) { ListViewItem item = myListView.get_Items().get_Item(iCtr); // Retrieve the text value for the column. String subItemText = item.get_SubItems().get_Item(column).get_Text(); // Use the initial letter instead if it is the first column. if (column == 0) { subItemText = subItemText.Substring(0, 1); } // If the groups table does not already contain a group // for the subItemText value, add a new group using the // subItemText value for the group header and Hashtable key. if (!(groups.Contains(subItemText))) { groups.Add(subItemText, new ListViewGroup(subItemText, HorizontalAlignment.Left)); } } // Return the Hashtable object. return groups; } //CreateGroupsTable

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ListViewGroup コンストラクタ (String, String)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ListViewGroup コンストラクタ (String)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ListViewGroup コンストラクタ

名前 | 説明 |
---|---|
ListViewGroup () | 既定の左揃えヘッダーで、"ListViewGroup" の既定のヘッダー テキストを使用して ListViewGroup クラスの新しいインスタンスを初期化します。 |
ListViewGroup (String) | Header プロパティの初期値を指定して、既定の左揃えヘッダーで ListViewGroup クラスの新しいインスタンスを初期化します。 |
ListViewGroup (String, HorizontalAlignment) | 指定されたヘッダー配置で、指定されたヘッダー テキストを使用して ListViewGroup クラスの新しいインスタンスを初期化します。 |
ListViewGroup (String, String) | Name プロパティと Header プロパティの初期値を指定して、ListViewGroup クラスの新しいインスタンスを初期化します。 |

ListViewGroup コンストラクタ ()
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


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に収録されているすべての辞書からListViewGroup コンストラクタを検索する場合は、下記のリンクをクリックしてください。

- ListViewGroup コンストラクタのページへのリンク