用C#要编写一个可用鼠标拖拽的BUTTON控件如何实现?

来源:百度知道 编辑:UC知道 时间:2024/05/29 05:06:25

上一个有点问题,我给改了一下
这会ok了。。。。

下边是全部代码。。。。。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Runtime.InteropServices;

namespace WindowsApplication1
{

public partial class Form1 : Form
{
Point pt;
bool moves = true;

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
if (moves == true)
{
MessageBox.Show("sfdfdf");
}
}

private void button1_MouseDown(object sender, MouseEventArgs e)
{
pt = Cursor.Position;
}