ListViewItem.Position Eigenschap

Definitie

Hiermee haalt of stelt u de positie van de linkerbovenhoek van de ListViewItem.

public:
 property System::Drawing::Point Position { System::Drawing::Point get(); void set(System::Drawing::Point value); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Point Position { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.Position : System.Drawing.Point with get, set
Public Property Position As Point

Waarde van eigenschap

De Point linkerbovenhoek van de ListViewItem.

Kenmerken

Uitzonderingen

De Position functie wordt ingesteld wanneer het bevat ListView zich in de virtuele modus bevindt.

Voorbeelden

In het volgende codevoorbeeld ziet u hoe u de Position eigenschap van een ListViewItem. Als u dit voorbeeld wilt uitvoeren, plakt u de volgende code in een Windows Formulier en roept u de InitializePositionedListViewItems aan uit de methode Load gebeurtenisafhandeling van het formulier. Klik op de knop om de items te zien die zijn verplaatst.

private ListView positionListView;
private ListViewItem moveItem;
private Button button1;

private void InitializePositionedListViewItems()
{
    // Set some basic properties on the ListView and button.
    positionListView = new ListView();
    positionListView.Height = 200;
    button1 = new Button();
    button1.Location = new Point(160, 30);
    button1.AutoSize = true;
    button1.Text = "Click to reposition";
    button1.Click += new System.EventHandler(button1_Click);

    // View must be set to icon view to use the Position property.
    positionListView.View = View.LargeIcon;
  
    // Create the items and add them to the ListView.
    ListViewItem item1 = new ListViewItem("Click");
    ListViewItem item2 = new ListViewItem("OK");
    moveItem = new ListViewItem("Move");
    positionListView.Items.AddRange(new ListViewItem[] 
        { item1, item2, moveItem });

    // Add the controls to the form.
    this.Controls.Add(positionListView);
    this.Controls.Add(button1);
}

private void button1_Click(object sender, EventArgs e)
{
    moveItem.Position = new Point(30, 30);
}
Private positionListView As ListView
Private moveItem As ListViewItem
Private WithEvents button1 As Button


Private Sub InitializePositionedListViewItems() 
    ' Set some basic properties on the ListView and button.
    positionListView = New ListView()
    positionListView.Height = 200
    button1 = New Button()
    button1.Location = New Point(160, 30)
    button1.AutoSize = True
    button1.Text = "Click to reposition"

    ' View must be set to icon view to use the Position property.
    positionListView.View = View.LargeIcon
    
    ' Create the items and add them to the ListView.
    Dim item1 As New ListViewItem("Click")
    Dim item2 As New ListViewItem("OK")
    moveItem = New ListViewItem("Move")
    positionListView.Items.AddRange(New ListViewItem() _
        {item1, item2, moveItem})
    
    ' Add the controls to the form.
    Me.Controls.Add(positionListView)
    Me.Controls.Add(button1)

End Sub

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    moveItem.Position = New Point(30, 30)
End Sub

Opmerkingen

De Position eigenschap moet worden ingesteld nadat de ListViewItem eigenschap is samengesteld en bevat ListView . Het wijzigen van de Position eigenschap wanneer de inhoud ListView zich in Details of List weergave bevindt, heeft geen invloed op de positie van de items. Position De eigenschap wordt ook automatisch gewijzigd wanneer de eigenschap van de View inhoud ListView wordt gewijzigd SmallIconvan , LargeIconof Tile weergave in List of Details. Als de ListView eigenschap voor een item is ingesteld SmallIconin , LargeIconof Tile als u de Position eigenschap voor een item instelt, worden de andere items in de ListView lijst opnieuw gerangschikt.

Van toepassing op

Zie ook