TEXT BOX WITH LONG TEXT GET TWO ROWS

Jeet Verma

Total Post:110

Points:776
Posted by  Jeet Verma
C# 
C#
 958  View(s)
Ratings:
Rate this:

I am using drag and drop from list box to text box and the problem when the item(string) is too long and I drag it to text box I see just the end of the text which was dragged and I see it in 2 rows ,how can I change it that when the long text is dragged to see the start of it if its bigger than the text box.

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: Text box with long text get two rows

    Hi Jeet,


    Try this code. This may help you.

        bool isTextDropped = false;

        void textBox_Drop(object sender, DragEventArgs e)

        {

            string tstring;

            tstring = e.Data.GetData(DataFormats.StringFormat).ToString();

            textBox.Text += " " + tstring;

            isTextDropped = true; 

        }      

        void textBox_TextChanged(object sender, TextChangedEventArgs e)

        {

            if (isTextDropped)

            {

                textBox.SelectionStart = 0;

                textBox.SelectionLength = 0;

                isTextDropped = false;

            }

        }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!