Click to See Complete Forum and Search --> : How can I position the caret in a text box to also be at the bottom of the text box?
chinniwhites
July 25th, 2005, 03:38 PM
I have a text box in my windows form that I use as a status window. It displays what the program is doing at all times. My problem is that when I do a DoEvents(), the text box always scrolls back up to the very top making the latest program events hidden. How can I make sure my text box always shows the very bottom instead of the top when I call DoEvents?
chinniwhites
July 26th, 2005, 10:42 AM
I was looking on the web and found some stuff on textbox->selectionstart and textbox->selectionlength. So I tried the following code to no avail:
txtStatus->Focus();
txtStatus->SelectionStart = txtStatus->Bottom;
txtStatus->SelectionLength = 0;
txtStatus->ScrollToCaret();
cmdStop->Focus();
chinniwhites
July 26th, 2005, 05:37 PM
Figured it out and figured I would let those curious about in on it as well. Pretty simple and here it is:
txtStatus->SelectionStart = txtStatus->Text->Length;
txtStatus->SelectionLength = 0;
txtStatus->ScrollToCaret();
Thats it. Short and sweet!
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.