winform drag and drop functionality
2012-02-22 12:54:25 GMT
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.
Sent from the Mono - WinForms mailing list archive at Nabble.com.
_______________________________________________ Mono-winforms-list maillist - Mono-winforms-list <at> lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list
RSS Feed