OnMouseMove not working while doing ListView item drag

S

stax

Hello,
can anybody tell me why OnMouseMove isn't working while doing a ListView item drag operation?

thx
stax



using System.Windows.Forms;

namespace WindowsApplication1
{
public class Form1 : Form
{
private ListView listView1;

public Form1()
{
InitializeComponent();

listView1.View = View.Details;

listView1.Columns.Add("11111");
listView1.Columns.Add("22222");

listView1.Items.Add(new ListViewItem(new string[] { "aaaaa", "bbbbb" }));
listView1.Items.Add(new ListViewItem(new string[] { "ccccc", "ddddd" }));
listView1.Items.Add(new ListViewItem(new string[] { "eeeee", "fffff" }));
}

#region Designer

private void InitializeComponent()
{
this.listView1 = new ListView();
this.SuspendLayout();
//
// listView1
//
this.listView1.AllowDrop = true;
this.listView1.Location = new System.Drawing.Point(54, 53);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(315, 279);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.DragEnter += new DragEventHandler(this.listView1_DragEnter);
this.listView1.MouseMove += new MouseEventHandler(this.listView1_MouseMove);
this.listView1.ItemDrag += new ItemDragEventHandler(this.listView1_ItemDrag);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(426, 405);
this.Controls.Add(this.listView1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

private void listView1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
}

private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
{
DoDragDrop(e.Item, DragDropEffects.Move);
}

private void listView1_MouseMove(object sender, MouseEventArgs e)
{
Text = Control.MousePosition.ToString();
}
}
}
 
C

ClayB

The DoDragDrop code captures the mouse so no other mouse events
(except drag events) are raised as control manages its drag. (You can
probably catch the coordinates in the DragOver event.)
===================
Clay Burch
Syncfusion, Inc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top