Share via


ListViewItem.Position Özellik

Tanım

öğesinin sol üst köşesinin ListViewItemkonumunu alır veya ayarlar.

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

Özellik Değeri

öğesinin Point sol üst köşesindeki ListViewItem.

Öznitelikler

Özel durumlar

Position, içeren ListView sanal moddayken ayarlanır.

Örnekler

Aşağıdaki kod örneği, özelliğinin PositionListViewItemnasıl kullanılacağını gösterir. Bu örneği çalıştırmak için aşağıdaki kodu bir Windows Formuna yapıştırın ve formun Load olay işleme yönteminden öğesini çağırınInitializePositionedListViewItems. Öğelerin yeniden konumlandırılmış olduğunu görmek için düğmeye tıklayın.

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

Açıklamalar

Position özelliği, ve içeren ListView oluşturulurken ListViewItem ayarlanmalıdır. Position veya List görünümünde olduğunda ListViewDetails özelliğini değiştirmenin öğelerin konumu üzerinde hiçbir etkisi olmaz. Ayrıca, içeren özelliğinin Position özelliği , LargeIconveya Tile görünümünden List veya Detailsolarak değiştirildiğinde View özelliği otomatik olarak değişirSmallIcon.ListView ListView, LargeIconveya Tile görünümünde olduğundaSmallIcon, bir öğenin özelliğini ayarlamak Position içinde yer alan ListView diğer öğelerin yeniden düzenlenmesine neden olur.

Şunlara uygulanır

Ayrıca bkz.