zoukankan      html  css  js  c++  java
  • 鼠标拖动控件

      /// <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

            

  • 相关阅读:
    Mysql游标的简明写法
    Sublime Text 介绍、用法、插件等
    [LeetCode#13] Roman to Integer
    [LeetCode#50] Pow(x, n)
    [LeetCode#240] Search a 2D Matrix II
    [LeetCode#238]Product of Array Except Self
    [LeetCode#171]Excel Sheet Column Number
    [LeetCode#258]Add Digits
    [LeetCode#264]Ugly Number II
    [LeetCode#263]Factorial Trailing Zeroes
  • 原文地址:https://www.cnblogs.com/superstar/p/1746527.html
Copyright © 2011-2022 走看看