sifenwang
2017-03-01 06:13
采纳率: 94.7%
浏览 1.7k

c# form上放置几个lable,每个lable之间用画直线连接,如何实现鼠标拖拽联动?求解

RT~
创建几个lable,然后每个lable之间画线连接,如何实现拖拽lable的同时,直线也跟着联动~~~急急急求解,lable的拖拽移动问题我已经解决了,关键是怎么让线跟着联动~~~
lable拖拽代码如下是:

                 lable1.MouseDown += new MouseEventHandler(Switch_MouseDown);
                lable1.MouseMove += new MouseEventHandler(Switch_MouseMove);
         private Point m_lastPoint;
        private Point m_lastMPoint;
        private void lable1_MouseDown(object sender, MouseEventArgs e)
        {
            m_lastMPoint = Control.MousePosition;
            m_lastPoint = (sender as Label).Location;
        }
        private void lable1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ((Label)sender).Location = new Point(m_lastPoint.X + Control.MousePosition.X - m_lastMPoint.X, m_lastPoint.Y + Control.MousePosition.Y - m_lastMPoint.Y);
            }
        }

3条回答 默认 最新

相关推荐 更多相似问题