c# form 无标题
引用:http://wenwen.soso.com/z/q237412855.htm
FormBorderStyle设置成None(一个窗体属性)
移动无标题窗口
【C#】[窗体]窗体无标题栏拖动
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 窗体拖动
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.FormBorderStyle=FormBorderStyle.None;//设置无标题栏
}
//--------窗体拖动---------
Point mouseOff;//鼠标移动位置变量
bool leftFlag;//标签是否为左键
//在窗体上按下发生事件
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)//如果按下的是鼠标左键
{
mouseOff = new Point(-e.X, -e.Y); //得到变量的值
leftFlag = true; //点击左键按下时标注为true;
}
}
//鼠标移动的事件
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (leftFlag)//如果鼠标左键是按下的状态
{
Point mouseSet = Control.MousePosition;
mouseSet.Offset(mouseOff.X, mouseOff.Y); //设置移动后的位置
Location = mouseSet;
}
}
//鼠标松开的事件
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
if (leftFlag)//如果鼠标左键是松开的状态
{
leftFlag = false;//释放鼠标后标注为false;
}
}
}
}
引用:http://www.cnblogs.com/isaced/archive/2011/01/24/1943224.html
参考:http://www.cnblogs.com/hongcing/archive/2010/02/05/1664433.html
form移动事件