我想让用户拖动任何项目从MenuStrip到列表框。 我之间做了ListBoxes,但不能用MenuStrip。 非常感谢您的帮助。C# - 拖动MenuStrip项目到列表框
我使用的WinForms,C#
对于目的地列表框我修改其属性 this.listBox2.AllowDrop = true;
并创建了以下两个事件:
private void listBox2_DragOver(
object sender, System.Windows.Forms.DragEventArgs e)
{
e.Effect=DragDropEffects.All;
}
private void listBox2_DragDrop(
object sender, System.Windows.Forms.DragEventArgs e)
{
if(e.Data.GetDataPresent(DataFormats.StringFormat))
{
string str= (string)e.Data.GetData(
DataFormats.StringFormat);
listBox2.Items.Add(str);
}
}
我需要的是什么应该做源的MenuStrip允许从ListBox中拖拽项目,以及如何使MenuStrip可拖拽。
感谢大家的帮助。
您可以发布您的代码吗?人们更容易指出你出错的地方。 – Steve
UI的技术是什么?的WinForms? WPF?您需要向我们展示一些代码 – Tomtom
我使用WinForms,C# –