鼠标进入Listbox后,鼠标指到哪,激活项的光标跟着指到那里.

解决方案 »

  1.   

    在 lv的mousemove事件里 加代码
      

  2.   

    重写ListBox的WndProc,当鼠标移动时,给ListBox发送鼠标单击的事件消息. public partial class MyListBox : ListBox
        {
            [DllImport("user32.dll")]
            public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);        public MyListBox()
            {
                InitializeComponent();
            }        protected override void WndProc(ref Message m)
            {
                base.WndProc(ref m);            Console.WriteLine(m.Msg.ToString());            switch (m.Msg)
                {
                    case 32:
                        SendMessage(this.Handle, 513, 0, 0);
                        break;
                    default:
                        break;
                }
            }
        }