“Pumpkin.Form1.lbxSource”是“字段”,但此处被当做“方法”来使用

c#


private int index = -1;  //选择的列表选项索引
        private void lbxSource_SelectedIndexChanged(object sender, EventArgs e)
        {
            index = lbxSource.SelectedIndex;  //获取当前列表选项的索引  
        }
        private void lbxSource_MouseDown(object sender, MouseEventArgs e)
        {
            if (this.lbxSource.SelectedItem == null)
            {
                return;
            }
            //开始拖放操作,DragDropEffects为枚举类型。
            //DragDropEffects.Move 为将源数据移动到目标数据
            this.lbxSource.DoDragDrop(this.lbxSource.SelectedItem, DragDropEffects.Move);
        }
        private void lbxSource_DragOver(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Move;
        }
        private void lbxSource_DragDrop(object sender, DragEventArgs e)
        {
            Point point = lbxSource.PointToClient(new Point(e.X, e.Y));
            int index = this.lbxSource.IndexFromPoint(point);
            if (index < 0)
            {
                index = this.lbxSource.Items.Count - 1;
            }
            //获取拖放的数据内容
            object data = e.Data.GetData(typeof(string));
            //删除原数据
            this.lbxSource.Items.Remove(data);
            //插入目标数据
            this.lbxSource.Items.Insert(index, data);
        }

“Pumpkin.Form1.lbxSource”是“字段”,但此处被当做“方法”来使用

看下报错的具体是哪一行,这个 lbxSource 应该是一个控件,但是具体是什么控件,你没有说清楚