鼠标拖动控件

  /// <summary>
    /// 用鼠标拖动Panel
    /// </summary>
    public class MovePanel : Panel
    {

        private bool whetherSelected = false;
        private Point p = new Point();
       
        public bool WhetherSelected
        {
            get { return whetherSelected; }
        }

        /// <summary>
        /// 重写,设置绘制
        /// </summary>
        protected override void OnCreateControl()
        {
            base.OnCreateControl();
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.DoubleBuffer, true);
        }
       
        /// <summary>
        /// OnMouseDown
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            whetherSelected = true;
            p.X = Cursor.Position.X;
            p.Y = Cursor.Position.Y;

        }

        /// <summary>
        /// OnMouseMove
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (whetherSelected == true)
            {
                if (this.IsParentMove)
                {
                    this.Parent.Left = this.Parent.Left + (Cursor.Position.X - p.X);
                    this.Parent.Top = this.Parent.Top + (Cursor.Position.Y - p.Y);
                }
                else
                {
                    this.Left = this.Left + (Cursor.Position.X - p.X);
                    this.Top = this.Top + (Cursor.Position.Y - p.Y);
                }
                    p.X = Cursor.Position.X;
                p.Y = Cursor.Position.Y;

            }

        }

        /// <summary>
        /// OnMouseUp
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            whetherSelected = false;
            this.BringToFront();
        }

        private bool _IsParentMove = false;
        /// <summary>
        /// 是否移动父控件
        /// </summary>
        public bool IsParentMove
        {

            get { return _IsParentMove; }
            set { _IsParentMove = value; }

        }       
    }

 

 

case when 示例 统计数量,经测试正常


select
(case
         when isn %2=0 then '自办营业厅'
         else
            'bb自办营业厅'
         end
) as b,
COUNT(*)
   from jb_zjm
   group by 
        
         (case
         when isn %2=0 then '自办营业厅'
         else
            'bb自办营业厅'
         end

        

posted @ 2010-05-28 17:45  superstar  阅读(264)  评论(0编辑  收藏  举报