建立窗體的名稱修改為:Form_HoverTree
文後附有源碼下載。
主要代碼:
Point _HoverTreePosition; public Form_HoverTree() { InitializeComponent(); _HoverTreePosition = new Point(); } /// <summary> /// 記錄鼠標起始位置 hovertree.com /// </summary> private void Form_HoverTree_MouseDown(object sender, MouseEventArgs e) { _HoverTreePosition.X = e.X; _HoverTreePosition.Y = e.Y; } /// <summary> /// 按住左鍵,鼠標移動窗體跟著移動 - 何問起 /// </summary> private void Form_HoverTree_MouseMove(object sender, MouseEventArgs e) { if(e.Button== MouseButtons.Left) { Point h_myPosittion = MousePosition; h_myPosittion.Offset(-_HoverTreePosition.X, -_HoverTreePosition.Y); Location = h_myPosittion; } }
效果圖:
可以看出,這個窗體為自定義形狀的窗體,沒有標題欄。具體參考:http://hovertree.com/h/bjaf/52nadvt4.htm
源碼下載:
http://hovertree.com/h/bjaf/j4wwteu3.htm
轉自:http://hovertree.com/h/bjaf/qewlrgqx.htm
推薦:
http://www.cnblogs.com/roucheng/p/DataGridView.html