Click here to Skip to main content
15,880,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,

iam adding text in listbox from two textboxes.like below
textbox1 text is 123
textbox2 text is sometext

after aded to list box1 is 123 sometext

now when i drag from listbox text 123 sometext to two other textboxes it should be drop to textbox3 is 123 and textbox4 is sometext,means when drag n drop text and number should be seperated.
plz help
Posted
Comments
[no name] 12-Sep-14 10:00am    
Okay and what is it that you need help with?
ZurdoDev 12-Sep-14 10:01am    
Where are you stuck?
george4986 13-Sep-14 0:52am    
post ur code here

1 solution

C#
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

C#
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
 
Share this answer
 
Comments
george4986 13-Sep-14 2:12am    
where u want to display the dragged data form1 or form2?
are u using form 2 for entering values to list?
after entering u are closing form 2 right?
BillWoodruff 13-Sep-14 4:55am    
Please add the code example to your original question/post. Posting a "solution" is meant to be exactly what it says: an answer to the original question, but, yes, sometimes folks do answer their own questions, and that's okay.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900