ListViewGroup コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ListViewGroup コンストラクタの意味・解説 

ListViewGroup コンストラクタ (String, HorizontalAlignment)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

指定されヘッダー配置で、指定されヘッダー テキスト使用して ListViewGroup クラス新しインスタンス初期化します。

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

Public Sub New ( _
    header As String, _
    headerAlignment As HorizontalAlignment _
)
Dim header As String
Dim headerAlignment As HorizontalAlignment

Dim instance As New ListViewGroup(header,
 headerAlignment)
public ListViewGroup (
    string header,
    HorizontalAlignment headerAlignment
)
public:
ListViewGroup (
    String^ header, 
    HorizontalAlignment headerAlignment
)
public ListViewGroup (
    String header, 
    HorizontalAlignment headerAlignment
)
public function ListViewGroup (
    header : String, 
    headerAlignment : HorizontalAlignment
)

パラメータ

header

グループ ヘッダー表示するテキスト

headerAlignment

ヘッダー テキスト配置指定する HorizontalAlignment 値の 1 つ

使用例使用例

詳細ビューサブ項目の値を使って 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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ListViewGroup コンストラクタ (String, String)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

Name プロパティHeader プロパティ初期値指定して、ListViewGroup クラス新しインスタンス初期化します。

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

Public Sub New ( _
    key As String, _
    headerText As String _
)
Dim key As String
Dim headerText As String

Dim instance As New ListViewGroup(key,
 headerText)
public ListViewGroup (
    string key,
    string headerText
)
public:
ListViewGroup (
    String^ key, 
    String^ headerText
)
public ListViewGroup (
    String key, 
    String headerText
)
public function ListViewGroup (
    key : String, 
    headerText : String
)

パラメータ

key

Name プロパティ初期値

headerText

Header プロパティ初期値

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ListViewGroup コンストラクタ (String)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

Header プロパティ初期値指定して既定左揃えヘッダーで ListViewGroup クラス新しインスタンス初期化します。

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

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ListViewGroup コンストラクタ


ListViewGroup コンストラクタ ()



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

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

辞書ショートカット

すべての辞書の索引

「ListViewGroup コンストラクタ」の関連用語

ListViewGroup コンストラクタのお隣キーワード
検索ランキング

   

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



ListViewGroup コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS