如何拖放相同和不同的列表框 [英] How to do drag and drop in same and different listbox

查看:95
本文介绍了如何拖放相同和不同的列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法使用两个不同的列表框拖放它并且它工作得很好但是如何在同一个列表框中拖放?



对不起,我还是新手。



我尝试了什么:



private void lisBox2_DragDrop(object sender,System.Windows.Forms.DragEventArgs e)

{

if(e.Data.GetDataPresent(DataFormats.StringFormat))

{

string str =(string)e.Data.GetData(DataFormats.StringFormat);



swapBetweenList(selectedIndex,movingIndex);



//lislis2.Items.Add(str);

}



}

解决方案

使用Drag-and-Drop ListBox [ ^ ]。



/拉维

I manage to do drag and drop using two different listbox and it works good but how to do the drag and drop in the same listbox ?

sorry i still new with this.

What I have tried:

private void lisBox2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.StringFormat))
{
string str = (string)e.Data.GetData(DataFormats.StringFormat);

swapBetweenList(selectedIndex, movingIndex);

//lisBox2.Items.Add(str);
}

}

解决方案

Use a Drag-and-Drop ListBox[^].

/ravi


这篇关于如何拖放相同和不同的列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆