B Beebs Sep 8, 2005 #1 How can I place the cursor at the end of the text in a textbox when the user presses a button?
G Guest Sep 8, 2005 #2 textbox.SelectionLength = 0; textbox.SelectionStart = textbox.TextLength-1; textbox.ScrollToCaret(); should do it
textbox.SelectionLength = 0; textbox.SelectionStart = textbox.TextLength-1; textbox.ScrollToCaret(); should do it
B Beebs Sep 8, 2005 #3 Thanks for the help, but I'm getting An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll on this line (I'm using VB .NET btw): textbox.SelectionStart = textbox.TextLength - 1 Any suggestions?
Thanks for the help, but I'm getting An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll on this line (I'm using VB .NET btw): textbox.SelectionStart = textbox.TextLength - 1 Any suggestions?
G Guest Sep 8, 2005 #4 Sure, if the textbox is empty, then TextLength - 1 evaluates to -1 and SelectionStart can't be < 0. You have to check for that case. -Chris
Sure, if the textbox is empty, then TextLength - 1 evaluates to -1 and SelectionStart can't be < 0. You have to check for that case. -Chris
S Sergey Bogdanov Sep 8, 2005 #5 .... and if you are going to append text into a TextBox you have to be aware of it: http://blog.opennetcf.org/afeinman/CommentView,guid,7e8df78c-a583-4b35-ae5d-02207210ab40.aspx
.... and if you are going to append text into a TextBox you have to be aware of it: http://blog.opennetcf.org/afeinman/CommentView,guid,7e8df78c-a583-4b35-ae5d-02207210ab40.aspx