this is form1
private void listBox1_MouseDown(object sender, MouseEventArgs e)
{
try
{
listBox1.DoDragDrop(listBox1.Items[listBox1.SelectedIndex].ToString(), DragDropEffects.Move);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void txtBox1_DragEnter(object sender, DragEventArgs e)
{
try
{
if (e.Data.GetDataPresent(DataFormats.Text))
{
e.Effect = DragDropEffects.Move;
}
else
{
e.Effect = DragDropEffects.None;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void txtBox1_DragDrop(object sender, DragEventArgs e)
{
txtwpAM1.Text = System.Convert.ToString(e.Data.GetData(DataFormats.Text).ToString());
}
this is my form2 code for add items like
textbox1 is 123 and textbox2 is sometext
private void button1_Click(object sender, EventArgs e)
{
_form.AddListBoxItem(textBox2.Text + "D"+ " "+textBox1.Text);
this.Close();
}
when i drag from listbox item it should be fired 123 is textbox2 and sometext is textbox1