Bu soruna geçici bir çözüm bulmak için <a0></a0>, Sürükle ve bırak işlevlerini ListView denetlemek için aşağıdaki gibi girin:
Aşağıdaki kodu ListView1_ItemDrag olay işleyicisine ekleyin.
Microsoft Visual Basic .NET'i veya Microsoft Visual Basic 2005 kodu
'Begins a drag-and-drop operation in the ListView control.
ListView1.DoDragDrop(ListView1.SelectedItems, DragDropEffects.Move)
Microsoft Visual C# .NET veya Microsoft Visual C# 2005 kod
//Begins a drag-and-drop operation in the ListView control.
listView1.DoDragDrop(listView1.SelectedItems, DragDropEffects.Move);
Aşağıdaki kodu ListView1_DragEnter olay işleyicisine ekleyin.
Visual Basic .NET veya Visual Basic 2005 kodu
Dim i As Integer
For i = 0 To e.Data.GetFormats().Length - 1
If e.Data.GetFormats()(i).Equals("System.Windows.Forms.ListView+SelectedListViewItemCollection") Then
'The data from the drag source is moved to the target.
e.Effect = DragDropEffects.Move
End If
Next
Visual C# .NET veya Visual C# 2005 kod
int len=e.Data.GetFormats().Length-1 ;
int i;
for (i = 0 ; i<=len ;i++)
{
if (e.Data.GetFormats()[i].Equals("System.Windows.Forms.ListView+SelectedListViewItemCollection"))
{
//The data from the drag source is moved to the target.
e.Effect = DragDropEffects.Move;
}
}
Aşağıdaki kodu ListView1_DragDrop olay işleyicisine ekleyin.
Visual Basic .NET veya Visual Basic 2005 kodu
'Return if the items are not selected in the ListView control.
If ListView1.SelectedItems.Count = 0 Then Return
'Returns the location of the mouse pointer in the ListView control.
Dim p As Point = ListView1.PointToClient(New Point(e.X, e.Y))
'Obtain the item that is located at the specified location of the mouse pointer.
Dim dragToItem As ListViewItem = ListView1.GetItemAt(p.X, p.Y)
If dragToItem Is Nothing Then Return
'Obtain the index of the item at the mouse pointer.
Dim dragIndex As Integer = dragToItem.Index
Dim i As Integer
Dim sel(ListView1.SelectedItems.Count) As ListViewItem
For i = 0 To ListView1.SelectedItems.Count - 1
sel(i) = ListView1.SelectedItems.Item(i)
Next
For i = 0 To ListView1.SelectedItems.Count - 1
'Obtain the ListViewItem to be dragged to the target location.
Dim dragItem As ListViewItem = sel(i)
Dim itemIndex As Integer = dragIndex
If itemIndex = dragItem.Index Then Return
If dragItem.Index < itemIndex Then
itemIndex = itemIndex + 1
Else
itemIndex = dragIndex + i
End If
'Insert the item in the specified location.
Dim insertitem As ListViewItem = dragItem.Clone
ListView1.Items.Insert(itemIndex, insertitem)
'Removes the item from the initial location while
'the item is moved to the new location.
ListView1.Items.Remove(dragItem)
Next
Visual C# .NET veya Visual C# 2005 kod
//Return if the items are not selected in the ListView control.
if(listView1.SelectedItems.Count==0)
{
return;
}
//Returns the location of the mouse pointer in the ListView control.
Point cp = listView1.PointToClient(new Point(e.X, e.Y));
//Obtain the item that is located at the specified location of the mouse pointer.
ListViewItem dragToItem = listView1.GetItemAt(cp.X, cp.Y);
if(dragToItem==null)
{
return;
}
//Obtain the index of the item at the mouse pointer.
int dragIndex = dragToItem.Index;
ListViewItem[] sel=new ListViewItem [listView1.SelectedItems.Count];
for(int i=0; i<=listView1.SelectedItems.Count-1;i++)
{
sel[i]=listView1.SelectedItems[i];
}
for(int i=0; i<sel.GetLength(0);i++)
{
//Obtain the ListViewItem to be dragged to the target location.
ListViewItem dragItem = sel[i];
int itemIndex = dragIndex;
if(itemIndex==dragItem.Index)
{
return;
}
if(dragItem.Index<itemIndex)
itemIndex++;
else
itemIndex=dragIndex+i;
//Insert the item at the mouse pointer.
ListViewItem insertItem = (ListViewItem)dragItem.Clone();
listView1.Items.Insert(itemIndex, insertItem);
//Removes the item from the initial location while
//the item is moved to the new location.
listView1.Items.Remove(dragItem);
}
Microsoft Visual Studio 2005 ya da Microsoft Visual Studio. NET'i başlatın.
Visual Basic .NET, Visual Basic 2005, Visual C# 2005 ve Visual C# .NET kullanarak yeni bir Windows uygulaması oluşturun.
Varsayılan olarak, Form1 oluşturulur.
ListView denetimi Form1'e ekleyin.
ListView1 ' ı sağ tıklatın ve sonra da Properties ' i tıklatın.
Özellikler iletişim kutusunu öğelerini tıklatın ve sonra da üç nokta düğmesini (...) tıklatın.
Listviewıtem koleksiyonu Düzenleyicisi) iletişim kutusunda, dört kez Ekle ' yi tıklatın.
Ikinci Listviewıtem denetimin metin özelliği Item2 için üçüncü Listviewıtem denetimin Text özelliği için Item3 ayarlayın ve sonra dördüncü Listviewıtem denetimin metin özelliği Item4 için Öğe1, ilk Listviewıtem denetimi Text özelliğini ayarlayın.
Listviewıtem koleksiyonu Düzenleyicisi) iletişim kutusunda, Tamam ' ı tıklatın.
ListView1özellikleri iletişim kutusunda, listegörünümü özelliğini ayarlayın.
ListView1AllowDrop'u özelli?inin true olarak ayarlayın.
Yapı) menüsünde tıklatın Build Solution.
Hata Ayıkla) menüsünde, Başlat ' ı tıklatın.
Öğe1ListView denetimindeki bir konuma sürüklemek, bu seçeneği deneyin.
Ek bilgi için, Microsoft Bilgi Bankası'ndaki makaleyi görüntülemek üzere aşağıdaki makale numarasını tıklatın:
822482
(http://support.microsoft.com/kb/822482/
)
NASıL YAPıLıR: Microsoft Visual Basic .NET kullanarak Microsoft Windows uygulamalarında Sürükle ve bırak işlevselliği sağlar.
ÖNEMLİ: Bu makale, bir kişi tarafından çevrilmek yerine, Microsoft makine-çevirisi yazılımı ile çevrilmiştir. Microsoft size hem kişiler tarafından çevrilmiş, hem de makine-çevrisi ile çevrilmiş makaleler sunar. Böylelikle, bilgi bankamızdaki tüm makalelere, kendi dilinizde ulaşmış olursunuz. Bununla birlikte, makine tarafından çevrilmiş makaleler mükemmel değildir. Bir yabancının sizin dilinizde konuşurken yapabileceği hatalar gibi, makale; kelime dağarcığı, söz dizim kuralları veya dil bilgisi açısından yanlışlar içerebilir. Microsoft, içeriğin yanlış çevrimi veya onun müşteri tarafından kullanımından doğan; kusur, hata veya zarardan sorumlu değildir. Microsoft ayrıca makine çevirisi yazılımını sıkça güncellemektedir.
Makalenin İngilizcesi aşağıdaki gibidir:822483
(http://support.microsoft.com/kb/822483/en-us/
)
Bu makaleyi kullanabilmek için kişisel olarak ne kadar çaba harcadınız?
Çok az
Az
Ne Az, Ne Fazla
Fazla
Çok fazla
Bu bilgiyi geliştirmek için ne yapabiliriz?
Gizliliğinizi korumak için, irtibat bilgilerinizi görüşlerinize eklemeyin.
Teşekkür ederiz! Görüşleriniz, destek içeriğimizi geliştirmek amacıyla kullanılacaktır. Daha fazla yardım seçeneği için lütfen, Yardım ve Destek Ana Sayfası’nı ziyaret edin.