问题
I have a custom RichTextBox Control derived from RichTextBox Control that Windows provides.
I am unable to capture the dragDrop Event though the DragEnter event is getting captured, but I dont know why the dragDrop event is not.
I have following properties set as true:
EnableAutoDragDrop=true;
AllowDrop=true;
What am I missing ??
回答1:
Daniel is probably correct here:
private void DragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
if (!e.Data.GetDataPresent(typeof(System.String))) {
e.Effect = DragDropEffects.None;
DropLocationLabel.Text = "None - no string data.";
return;
}
see also the example in:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dodragdrop.aspx
回答2:
You need DragDrop and DragOver in your RichTextBox.
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_26532918.html
Set EnableAutoDragDrop=false or your user will have 2 entries(1 duplicate) rather than just one entry. Eg. user picks"cat5" and when dropped in RichTextBox "cat5" appears twice.
回答3:
Just a guess - maybe you missed to correctly set the drag'n'drop effect.
来源:https://stackoverflow.com/questions/1465988/capture-dragdrop-event-of-richtextbox-c-sharp