zoukankan      html  css  js  c++  java
  • 在C#中,实现可拖动控件,并显示控件的坐标位置

    private   Point   mouse_offset;

    private   void   Control_MouseDown(object   sender,System.Windows.Forms.MouseEventArgs   e)
    {
                mouse_offset   =   new   Point(-e.X,-e.Y);
    }

    private   void   Control_MouseMove(object   sender,System.Windows.Forms.MouseEventArgs   e)
    {
          if   (e.Button   ==   MouseButtons.Left)
          {
                Point   mousePos   =   Control.MousePosition;
                mousePos.Offset(mouse_offset.X,   mouse_offset.Y);
                ((Control)sender).Location   =   ((Control)sender).Parent.PointToClient(mousePos);
          }

      this.label1.Text ="横坐标:"+mouse_offset.X+"纵坐标"+mouse_offset.Y;
    }

  • 相关阅读:
    双向(端)链表、栈、队列
    WPF 3D基础(1)
    静态查找
    栈和队列 迷宫求解
    异步编程Demo
    WPF 3D基础(2)
    串操作
    链栈和链队
    Linux恢复数据
    word文件修复窍门
  • 原文地址:https://www.cnblogs.com/yuxuan/p/1834330.html
Copyright © 2011-2022 走看看