Capture DragDrop Event of RichTextBox C#

独自空忆成欢 提交于 2019-12-11 08:38:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!