Skip to content

Instantly share code, notes, and snippets.

@orellabac
Created August 10, 2016 18:11
Show Gist options
  • Save orellabac/e74145b829a1218b6a4ef4bc8051327e to your computer and use it in GitHub Desktop.
Save orellabac/e74145b829a1218b6a4ef4bc8051327e to your computer and use it in GitHub Desktop.
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//Do this to allow drap operations
this.AllowDrop = true;
this.Label1.AllowDrop = true;
}
private void Command1_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form_DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
var source = e.GetSource();
}
private void Label1_DragDrop(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
var source = e.GetSource();
Label1.Text = source.Text;
}
private void Label1_DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
var source = e.GetSource();
}
private void Text1_MouseDown(object sender, MouseEventArgs e)
{
if (Text1.Text.Length > 0 && e.Button == MouseButtons.Left)
{
Text1.BeginDrag();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment