Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2007

Tip: Looking for answers? Try searching our database.

OnMouseMove not working while doing ListView item drag

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
stax - 20 Feb 2007 13:35 GMT
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();
        }
    }
}
ClayB - 20 Feb 2007 15:51 GMT
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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.