views:

567

answers:

4

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 ??

A: 

Just a guess - maybe you missed to correctly set the drag'n'drop effect.

Daniel Brückner
+2  A: 

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

csharptest.net
A: 

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.

mas_oz2k1
A: 

i think the question is richtextbox may not accept the object which you drag.

bob