AceInfinity
Emeritus, Contributor
Code:
using System;
using System.Drawing;
using System.Windows.Forms;
class FileDropTextBox : TextBox
{
public FileDropTextBox()
{
AllowDrop = true;
}
private string _OldText;
protected override void OnDragEnter(DragEventArgs drgevent)
{
base.OnDragEnter(drgevent);
if (drgevent.Data.GetDataPresent(DataFormats.FileDrop))
{
drgevent.Effect = DragDropEffects.Copy;
this.ForeColor = Color.FromArgb(255, 150, 150, 150);
_OldText = this.Text;
this.Text = ((string[])drgevent.Data.GetData(DataFormats.FileDrop))[0];
}
}
protected override void OnDragDrop(DragEventArgs drgevent)
{
base.OnDragDrop(drgevent);
if (drgevent.Data.GetDataPresent(DataFormats.FileDrop))
this.ForeColor = Color.FromArgb(255, 0, 0, 0);
}
protected override void OnDragLeave(EventArgs e)
{
base.OnDragLeave(e);
this.ForeColor = Color.FromArgb(255, 0, 0, 0);
this.Text = _OldText;
}
}
I thought this was a cool idea that I came up with so i'll share it with the rest of you :)
Preview:
This is something I've specifically written for implementation in AutoBSA++, but perhaps someone else will find this useful too!