Hi,
I have a richtextbox which I like to clear after entering.
So I have an event which works fine $richtextbox.Clear(), but the cursor should be again at top of richtextbox and now is on a second line (because of the enter).
Please advise howto correct that, a full reset of the RichTextbox somehow?
S.
Bring cursor to top in richtextbox after enter then
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Bring cursor to top in richtextbox after enter then
Because that's the way I ask an enduser to enter data. The whole design of the form/project is build upon this input by running enter afer input.
Re: Bring cursor to top in richtextbox after enter then
What does that have to do with clearing the box? Are you using the enter key to execute the clear method? That doesn't make any sense. Don't mix input methods with control methods.
Re: Bring cursor to top in richtextbox after enter then
When enter is done, the textbox should be cleared to enter new text. It's a chatbot form I m making so once text is typed and entered, the textbox should be empty to enter new text.
Re: Bring cursor to top in richtextbox after enter then
THat doesn't give us a clue as to what you are doing or how you are trying to do it. If you have a button that executes the "Clear()" method it will completely clear the box.
Note that when you use the enter key to end an input then the focus will move to the next control. If you try to detect the enter as a termination then you are not doing something that can work unless you cancel the event. That would depend on the event as not all events can be cancelled.
Note that when you use the enter key to end an input then the focus will move to the next control. If you try to detect the enter as a termination then you are not doing something that can work unless you cancel the event. That would depend on the event as not all events can be cancelled.
Re: Bring cursor to top in richtextbox after enter then
Fair enough.
Thanks for your input on the matter.
Thanks for your input on the matter.
Re: Bring cursor to top in richtextbox after enter then
I posted the script (example of it) here: viewtopic.php?p=82544#p82544
That to clarify why I do use the enter. Would appreciate your input!
That to clarify why I do use the enter. Would appreciate your input!
Re: Bring cursor to top in richtextbox after enter then
Read this about the args in the event: https://docs.microsoft.com/en-us/dotnet ... gs-handled
You need to add this after the "Clear()" -
$_.Handled = $true
You may also need to change how the box handles the "Enter" character. You shouldn't have to refocus when you are trying to detect that character.
You need to add this after the "Clear()" -
$_.Handled = $true
You may also need to change how the box handles the "Enter" character. You shouldn't have to refocus when you are trying to detect that character.
Re: Bring cursor to top in richtextbox after enter then
Thanks!
About your remark: not sure howto deal with it differently?
About your remark: not sure howto deal with it differently?