【发布时间】:2018-12-21 02:47:38
【问题描述】:
我正在尝试使用 tutorial 实现拖放功能
所以首先我先用DataSource 填充,比如:
var techListQuery = $"exec getEmployeeListMailing";
var techList = db.GetTableBySQL(techListQuery);
lstTechUnnotified.DataSource = techList;
lstTechUnnotified.DisplayMember = "Abbreviation";
lstTechUnnotified.ValueMember = "UserName";
一旦我这样做了,我就有了Mouse_Down 第一个列表框的事件,但是当它尝试从第一个列表中删除项目时问题就开始了:
if (dde1 == DragDropEffects.All)
{
lstTechUnnotified.Items.RemoveAt(lstTechUnnotified.IndexFromPoint(e.X, e.Y));
}
我收到消息:
'当 DataSource 属性为 设置
我能做些什么来解决这个问题?问候
【问题讨论】:
-
错误信息很清楚。当 ListBox 具有 DataSource 时,您不能修改它。而是从数据源中删除该项,然后重新设置 ListBox 的 DataSource 属性。
标签: winforms drag-and-drop listbox