日期:2014-05-18 浏览次数:20800 次
void listView1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { ListViewItem item = listView1.GetItemAt(e.X,e.Y); item.Selected = true; } } Point pos = new Point(); void pictureBox1_MouseUp(object sender, MouseEventArgs e) { pos.X = e.X; pos.Y = e.Y; } void pictureBox1_DragDrop(object sender, DragEventArgs e) { string[] str = e.Data.GetFormats(); if (str.Length == 0) return; Label lab = e.Data.GetData(str[0]) as Label; lab.BackColor = Color.Gray; pictureBox1.Controls.Add(lab); lab.Location = pos; } void pictureBox1_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(Label))) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; }
------解决方案--------------------
原则上说用点击就可以实现了
如果要用拖的话就得用API去捕捉了,没必要费这功夫啊
------解决方案--------------------
7楼的已经说得很清楚了
------解决方案--------------------
收藏