研究过窗体设计器的都知道,鼠标事件几乎都被屏蔽掉,都被用去做拖动和选择的一些功能。
重新添加鼠标事件的方式如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.ComponentModel.Design;
using System.Windows.Forms;
namespace DesignSurfaceExt
{
public enum MyMouseButtons
{
Leave = 0,//鼠标移出
Move,//鼠标移入
LeftDown,//鼠标左键down
LeftUp, //鼠标左键up
DoubleClick,//鼠标双击
RightDown,//鼠标右键down
RightUp,//鼠标右键up
Wheel//鼠标滚轮动
}
public class EventMouse : System.Windows.Forms.Design.ControlDesigner
{
private MyMouseButtons MouseState = 0;
private ISelectionService SelectionService
{
get
{
return this.GetService(typeof(ISelectionService)