WinForm支持拖拽效果
来源:互联网 发布:台湾衰落知乎 编辑:程序博客网 时间:2024/05/16 15:44
using Microsoft.VisualBasic;using System;using System.Collections;using System.Collections.Generic;using System.Data;using System.Diagnostics;public class Form1{ //计数变量,说明输出了第N个Button private int count = 1; private void Form1_Load(System.Object sender, System.EventArgs e) { this.AllowDrop = true; //窗体自身支持接受拖拽来的控件 } private void Button1_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e) { //左键的话,标志位为true(表示拖拽开始) if ((e.Button == System.Windows.Forms.MouseButtons.Left)) { Button1.DoDragDrop(Button1, DragDropEffects.Copy | DragDropEffects.Move); //形成拖拽效果,移动+拷贝的组合效果 } } private void Form1_DragEnter(System.Object sender, System.Windows.Forms.DragEventArgs e) { //当Button被拖拽到WinForm上时候,鼠标效果出现 if ((e.Data.GetDataPresent(typeof(Button)))) { e.Effect = DragDropEffects.Copy; } } private void Form1_DragDrop(System.Object sender, System.Windows.Forms.DragEventArgs e) { //拖放完毕之后,自动生成新控件 Button btn = new Button(); btn.Size = Button1.Size; btn.Location = this.PointToClient(new Point(e.X, e.Y)); //用这个方法计算出客户端容器界面的X,Y坐标。否则直接使用X,Y是屏幕坐标 this.Controls.Add(btn); btn.Text = "按钮" + count.ToString(); count = count + 1; } public Form1() { DragDrop += Form1_DragDrop; DragEnter += Form1_DragEnter; Load += Form1_Load; }}原文地址:http://www.cnblogs.com/ServiceboyNew/archive/2012/04/29/2476154.html
0 0
- Winform支持拖拽效果
- WinForm支持拖拽效果
- WinForm支持拖拽效果
- WinForm支持拖拽效果
- C# winform 拖拽效果
- C# Winform 的淡入淡出效果 及 控件拖拽效果
- C# winform 渐变效果
- winform动画效果
- Winform窗体效果
- winform窗体抖动效果
- Winform 拖拽控件
- winform的TreeView动画效果
- winform窗体添加动态效果
- Winform实现Visual Studio效果
- winForm欢迎界面,渐变效果
- WinForm 窗体缩放动画效果
- C# WINFORM TEXTBOX水印效果
- C# winform textbox 水印效果
- 一切成功源于积累——20140730 美瑞 上演疯狂-3
- Java NIO读书笔记
- netbeans 的数据库实体类dataentity的BUG
- 百度轻应用视频
- 凯撒密码
- WinForm支持拖拽效果
- Xcode 常用快捷键
- mysql密码忘记解决办法
- POJ 2584 T-Shirt Gumbo(网络流之最大流)
- php download pictures
- Python 的内存管理
- 双边滤波器的原理及实现
- 终于把 VIJOS 源代码调试好了
- pwd