日期:2014-05-18  浏览次数:20899 次

WinForm界面上如何拖动控件?
做一个类似VS的东西,能够在界面上用鼠标点击的方式添加控件,添加的控件可以拖动,以更改位置...应该怎么弄呢?或者哪位高手 有一些这样的小玩意..给我发一下QQ317648720 谢谢了

------解决方案--------------------
你看看VS里面有一个叫什么visualstdio.desinger类的.
具体忘了,你查一下,专门介绍做类似VS的东西

------解决方案--------------------
C# code
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        [DllImport("user32.dll")]
        static extern bool ReleaseCapture();
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, UInt32 wParam, UInt32 lParam);

        private readonly UInt32 WM_SYSCOMMAND = 0x112;
        private readonly UInt32 SC_MOVE = 0xF010;
        private readonly UInt32 HTCAPTION = 2;

        private void button1_MouseDown(object sender, MouseEventArgs e)
        {
            ReleaseCapture();
            SendMessage(button1.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
        }

        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            ReleaseCapture();
            SendMessage(pictureBox1.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
        }

        private void textBox1_MouseDown(object sender, MouseEventArgs e)
        {
            ReleaseCapture();
            SendMessage(textBox1.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
        }
    }
}

------解决方案--------------------
http://www.cnblogs.com/xkxjy/archive/2009/04/27/2078103.html
------解决方案--------------------
你去下载个sharpdevelop
那是仿VS软件,还是开源的