[Mono-winforms-list] winform drag and drop functionality

savita savita.dhole at ness.com
Wed Feb 22 12:54:25 UTC 2012


Hi,

We have developed a drag and drop functionality in .net win form using c#. 
drag sourse is list box
drag target is textbox.

It doesn't give any error when compiled in mono. However the drag and drop
functionality doesn't work in mono. The text in texbox set as a blank when
dragged a list item from listbox. It works fine in .net.
Kindly help and let me know what I am missing.

I have set the 

this.textBox1.AllowDrop = true;
this.listBox1.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.listBox1_MouseDown);
this.textBox1.DragDrop += new
System.Windows.Forms.DragEventHandler(this.textBox1_DragDrop);
this.textBox1.DragEnter += new
System.Windows.Forms.DragEventHandler(this.textBox1_DragEnter);
--------------------------------------------
 public Form1()
        {
            InitializeComponent();
            listBox1.Items.Add("ABC");
            listBox1.Items.Add("XYZ");
            listBox1.Items.Add("AAA");
        }

        private void textBox1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.Text))
                e.Effect = DragDropEffects.Copy;
            else
                e.Effect = DragDropEffects.None;

        }        

        private void textBox1_DragDrop(object sender, DragEventArgs e)
        {

            textBox1.Text =
(string)e.Data.GetData(DataFormats.StringFormat); ;
         
        }



        private void listBox1_MouseDown(object sender, MouseEventArgs e)
        {
            
            listBox1.DoDragDrop(listBox1.SelectedItem.ToString(),
DragDropEffects.Copy);
         

        }
---------------------------------------------------------

Note : I have also refered the 'Dragging Text' code from
http://zetcode.com/tutorials/monowinformstutorial/dragdrop/ . This also
doesn't work when compiled in mono.

--
View this message in context: http://mono.1490590.n4.nabble.com/winform-drag-and-drop-functionality-tp4410189p4410189.html
Sent from the Mono - WinForms mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-winforms-list/attachments/20120222/934d1195/attachment.html>


More information about the Mono-winforms-list mailing list