ListViewItem.Group プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ListViewItem.Group プロパティの意味・解説 

ListViewItem.Group プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

項目が割り当てられているグループ取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

<LocalizableAttribute(True)> _
Public Property Group As
 ListViewGroup
Dim instance As ListViewItem
Dim value As ListViewGroup

value = instance.Group

instance.Group = value
[LocalizableAttribute(true)] 
public ListViewGroup Group { get; set;
 }
[LocalizableAttribute(true)] 
public:
property ListViewGroup^ Group {
    ListViewGroup^ get ();
    void set (ListViewGroup^ value);
}
/** @property */
public ListViewGroup get_Group ()

/** @property */
public void set_Group (ListViewGroup value)
public function get Group
 () : ListViewGroup

public function set Group
 (value : ListViewGroup)

プロパティ
項目の割り当て先の ListViewGroup。

解説解説
使用例使用例

詳細ビューサブ項目の値を使って ListView 項目を整理するアプリケーションで、Group プロパティ使用する方法次のコード例示します。この形式グループ化は、Windows エクスプローラ使用されているグループ化似てます。この例では、グループ動的に作成されます。サブ項目列では、一意サブ項目値ごとに 1 つグループ作成されます。親項目列では、一意先頭文字ごとに 1 つグループ作成されます。各列について作成されグループは、サブ項目のテキストまたは先頭文字と共にハッシュ テーブル格納されます。ヘッダークリックされると、その列に対応するハッシュ テーブル取得されます。次に、その列のサブ項目テキストの値がハッシュ テーブルキーとして使用されて、各項目の正確なグループ取得されます。次にGroup プロパティ使用して、その項目がグループ割り当てられます。

このコード例ListView.Groups プロパティ例の "一部" です。

' Sets myListView to the groups created for the specified column.
Private Sub SetGroups(column As
 Integer)
    ' Remove the current groups.
    myListView.Groups.Clear()
    
    ' Retrieve the hash table corresponding to the column.
    Dim groups As Hashtable = CType(groupTables(column),
 Hashtable)
    
    ' Copy the groups for the column to an array.
    Dim groupsArray(groups.Count - 1) As ListViewGroup
    groups.Values.CopyTo(groupsArray, 0)
    
    ' Sort the groups and add them to myListView.
    Array.Sort(groupsArray, New ListViewGroupSorter(myListView.Sorting))
    myListView.Groups.AddRange(groupsArray)
    
    ' Iterate through the items in myListView, assigning each 
    ' one to the appropriate group.
    Dim item As ListViewItem
    For Each item In myListView.Items
        ' Retrieve the subitem text corresponding to the column.
        Dim subItemText As String
 = item.SubItems(column).Text
        
        ' For the Title column, use only the first letter.
        If column = 0 Then
            subItemText = subItemText.Substring(0, 1)
        End If 

        ' Assign the item to the matching group.
        item.Group = CType(groups(subItemText), ListViewGroup)
    Next item
End Sub 'SetGroups
// Sets myListView to the groups created for the specified column.
private void SetGroups(int
 column)
{
    // Remove the current groups.
    myListView.Groups.Clear();

    // Retrieve the hash table corresponding to the column.
    Hashtable groups = (Hashtable)groupTables[column];

    // Copy the groups for the column to an array.
    ListViewGroup[] groupsArray = new ListViewGroup[groups.Count];
    groups.Values.CopyTo(groupsArray, 0);

    // Sort the groups and add them to myListView.
    Array.Sort(groupsArray, new ListViewGroupSorter(myListView.Sorting));
    myListView.Groups.AddRange(groupsArray);

    // Iterate through the items in myListView, assigning each 
    // one to the appropriate group.
    foreach (ListViewItem item in myListView.Items)
    {
        // Retrieve the subitem text corresponding to the column.
        string subItemText = item.SubItems[column].Text;

        // For the Title column, use only the first letter.
        if (column == 0) 
        {
            subItemText = subItemText.Substring(0, 1);
        }

        // Assign the item to the matching group.
        item.Group = (ListViewGroup)groups[subItemText];
    }
}
   // Sets myListView to the groups created for the specified column.
private:
   void SetGroups(int column)
   {
      // Remove the current groups.
      myListView->Groups->Clear();

      // Retrieve the hash table corresponding to the column.
      Hashtable^ groups = dynamic_cast<Hashtable^>(groupTables[column]);

      // Copy the groups for the column to an array.
      array<ListViewGroup^>^ groupsArray = gcnew array<ListViewGroup^>(groups->Count);
      groups->Values->CopyTo(groupsArray, 0);

      // Sort the groups and add them to myListView.
      Array::Sort(groupsArray, gcnew ListViewGroupSorter(myListView->Sorting));
      myListView->Groups->AddRange(groupsArray);

      // Iterate through the items in myListView, assigning each 
      // one to the appropriate group.
      IEnumerator^ myEnum = myListView->Items->GetEnumerator();
      while (myEnum->MoveNext())
      {
         ListViewItem^ item = safe_cast<ListViewItem^>(myEnum->Current);
         // Retrieve the subitem text corresponding to the column.
         String^ subItemText = item->SubItems[column]->Text;

         // For the Title column, use only the first letter.
         if (column == 0) 
         {
            subItemText = subItemText->Substring(0, 1);
         }

         // Assign the item to the matching group.
         item->Group = dynamic_cast<ListViewGroup^>(groups[subItemText]);
      }
   }
// Sets myListView to the groups created for the specified column.
private void SetGroups(int
 column)
{
    // Remove the current groups.
    myListView.get_Groups().Clear();
    // Retrieve the hash table corresponding to the column.
    Hashtable groups = (Hashtable)groupTables.get_Item(column);
    // Iterate through the items in myListView, assigning each 
    // one to the appropriate group.
    for (int iCtr = 0; iCtr < myListView.get_Items().get_Count();
 iCtr++) {
        ListViewItem item = myListView.get_Items().get_Item(iCtr);
        // Retrieve the subitem text corresponding to the column.
        String subItemText = item.get_SubItems().get_Item(column).get_Text();
        // For the Title column, use only the first letter.
        if (column == 0) {
            subItemText = subItemText.Substring(0, 1);
        }
        // Assign the item to the matching group.
        item.set_Group((ListViewGroup)(groups.get_Item(subItemText)));
    }
    // Copy the groups for the column to an array.
    ListViewGroup groupsArray[] = new ListViewGroup[groups.get_Count()];
    groups.get_Values().CopyTo(groupsArray, 0);
    // Sort the groups and add them to myListView.
    Array.Sort(groupsArray, new ListViewGroupSorter(
        myListView.get_Sorting()));
    myListView.get_Groups().AddRange(groupsArray);
} //SetGroups
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からListViewItem.Group プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からListViewItem.Group プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からListViewItem.Group プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ListViewItem.Group プロパティ」の関連用語

ListViewItem.Group プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ListViewItem.Group プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS