Always Displaying The Last Text In A Scrolling Text Box
Posted on 2009-12-29
I'm implimenting a simple chat application in Microsoft Access.
On a form will be the TextBox "ChatText" which will be the history of the chat session to date between two users. The ChatTextToAdd box will contain the text the user will type and then when submitted this new line will be added to the end of the ChatText text box and so on.
This works ok until the ChatText box has quite a few lines and then it disappears off the screen. Scroll bars added means the user can scroll to see the later lines but what I want is for the ChatText textbox to always display the last lines, i.e. the cursor remain at the end of the text even when the field does not have the focus.
I can use:
Forms("CHAT").Controls("ChatText").SelStart = Forms("CHAT").Controls("ChatText").SelLength
However when the focus moves away from the ChatText field and onto the ChatTextToAdd for example (when user goes to submit a new line to the chat), the ChatText tetx box reverts back to the beginning of the text and the later lines disappear again.
I have considered using a mono-spaced font and counting the length of each submitted line and the number of carriage returns etc to truncate the displayed text so that only the last few lines are display but I prefer to use a proportionately spaced font.
Any ideas anyone ?