dotnet / dotnet/dotnet-api-docs

Don't need to clone draggedItem

Open
#1,063 1 comment 0 reactions 0 assignees View on GitHub
area-WinForms dotnet-api/prod Pri2 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

@lulianqi commented on [Sat Nov 03 2018](https://github.com/dotnet/dotnet-api-docs.zh-cn/issues/3)

draggedItem will not dispose when remove
so we can Insert it still

maybe below code will be better (in the myListView_DragDrop)

```
int targetIndex = myListView.InsertionMark.Index;
if (targetIndex == -1)
{
return;
}
ListViewItem draggedItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));
myListView.Items.Remove(draggedItem);
myListView.Items.Insert( targetIndex, draggedItem);
```

---
#### 文档详细信息

⚠ *请勿编辑此部分。 docs.microsoft.com ➟ GitHub 问题链接必须具有此部分。*

* ID: 05bde473-96e7-99c5-8248-a2b8387febec
* Version Independent ID: 7d3652ed-efda-62c8-0c9f-8cc9d728d147
* Content: [ListView.InsertionMark Property (System.Windows.Forms)](https://docs.microsoft.com/zh-cn/dotnet/api/system.windows.forms.listview.insertionmark?redirectedfrom=MSDN&view=netframework-4.7.2#System_Windows_Forms_ListView_InsertionMark)
* Content Source: [xml/System.Windows.Forms/ListView.xml](https://github.com/dotnet/dotnet-api-docs.zh-cn/blob/live/xml/System.Windows.Forms/ListView.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.