ListViewGroup Costruttori
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Inizializza una nuova istanza della classe ListViewGroup.
Overload
| Nome | Descrizione |
|---|---|
| ListViewGroup() |
Inizializza una nuova istanza della ListViewGroup classe utilizzando il testo di intestazione predefinito "ListViewGroup" e l'allineamento dell'intestazione sinistra predefinito. |
| ListViewGroup(String) |
Inizializza una nuova istanza della ListViewGroup classe utilizzando il valore specificato per inizializzare la Header proprietà e utilizzando l'allineamento dell'intestazione sinistra predefinito. |
| ListViewGroup(String, String) |
Inizializza una nuova istanza della ListViewGroup classe utilizzando i valori specificati per inizializzare le Name proprietà e Header . |
| ListViewGroup(String, HorizontalAlignment) |
Inizializza una nuova istanza della ListViewGroup classe utilizzando il testo dell'intestazione specificato e l'allineamento dell'intestazione specificato. |
ListViewGroup()
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
Inizializza una nuova istanza della ListViewGroup classe utilizzando il testo di intestazione predefinito "ListViewGroup" e l'allineamento dell'intestazione sinistra predefinito.
public:
ListViewGroup();
public ListViewGroup();
Public Sub New ()
Si applica a
ListViewGroup(String)
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
Inizializza una nuova istanza della ListViewGroup classe utilizzando il valore specificato per inizializzare la Header proprietà e utilizzando l'allineamento dell'intestazione sinistra predefinito.
public:
ListViewGroup(System::String ^ header);
public ListViewGroup(string header);
public ListViewGroup(string? header);
new System.Windows.Forms.ListViewGroup : string -> System.Windows.Forms.ListViewGroup
Public Sub New (header As String)
Parametri
- header
- String
Testo da visualizzare per l'intestazione del gruppo.
Si applica a
ListViewGroup(String, String)
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
Inizializza una nuova istanza della ListViewGroup classe utilizzando i valori specificati per inizializzare le Name proprietà e Header .
public:
ListViewGroup(System::String ^ key, System::String ^ headerText);
public ListViewGroup(string key, string headerText);
public ListViewGroup(string? key, string? headerText);
new System.Windows.Forms.ListViewGroup : string * string -> System.Windows.Forms.ListViewGroup
Public Sub New (key As String, headerText As String)
Parametri
Si applica a
ListViewGroup(String, HorizontalAlignment)
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
- Origine:
- ListViewGroup.cs
Inizializza una nuova istanza della ListViewGroup classe utilizzando il testo dell'intestazione specificato e l'allineamento dell'intestazione specificato.
public:
ListViewGroup(System::String ^ header, System::Windows::Forms::HorizontalAlignment headerAlignment);
public ListViewGroup(string header, System.Windows.Forms.HorizontalAlignment headerAlignment);
public ListViewGroup(string? header, System.Windows.Forms.HorizontalAlignment headerAlignment);
new System.Windows.Forms.ListViewGroup : string * System.Windows.Forms.HorizontalAlignment -> System.Windows.Forms.ListViewGroup
Public Sub New (header As String, headerAlignment As HorizontalAlignment)
Parametri
- header
- String
Testo da visualizzare per l'intestazione del gruppo.
- headerAlignment
- HorizontalAlignment
Uno dei HorizontalAlignment valori che specifica l'allineamento del testo dell'intestazione.
Esempio
Nell'esempio di codice seguente viene illustrato come usare il ListViewGroup costruttore in un'applicazione che organizza gli ListView elementi in base al valore dell'elemento secondario nella visualizzazione dei dettagli. Questa forma di raggruppamento è simile al raggruppamento usato in Esplora risorse. Nell'esempio i gruppi vengono creati in modo dinamico. Per ogni colonna dell'elemento secondario, viene creato un gruppo per ogni valore dell'elemento secondario univoco. Per la colonna dell'elemento padre, viene creato un gruppo per ogni lettera iniziale univoca. I gruppi creati per ogni colonna vengono archiviati in una tabella hash insieme al testo dell'elemento secondario o alla lettera iniziale. Quando si fa clic su un'intestazione di colonna, questo valore di testo viene usato per associare gli elementi ai gruppi per la colonna appropriata.
Per l'esempio completo, vedere l'argomento di riferimento di ListViewGroup panoramica.
// 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.
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 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