Winforms: how to use cursor keys to select text?

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ic2
Posts: 1856
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Winforms: how to use cursor keys to select text?

Post by ic2 »

In VO we use a MultiLineEdit control to select multiple text fragments from the content. Each time a user has selected some text they click a button and then can continue to select the next fragment or finish. The user can do that with the mouse but also scroll down with cursor keys and select text with the usual combination like Ctrl cursor.

Our X# converted-prg-in-progress uses Winforms and I found out that nor a TextBox, nor a RichEdit control seem to do anything with cursor keys. Not for selecting and not for browsing down through the text.

Is there any way to enable that, or otherwise an alternative control where this does work?

Dick
User avatar
Chris
Posts: 4845
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Winforms: how to use cursor keys to select text?

Post by Chris »

Hi Dick,

for the TextBox, you can use Select(start,length) to select some text. Also with ScrollToCaret(), you can make it scroll so that the caret/start of selected text is visible. Finally, with HideSelection := FALSE you can make the selected text be always visible as selected, even if the control doesn't currently have focus.

https://learn.microsoft.com/en-us/dotne ... work-4.8.1
https://learn.microsoft.com/en-us/dotne ... work-4.8.1
https://learn.microsoft.com/en-us/dotne ... work-4.8.1

.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1856
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Winforms: how to use cursor keys to select text?

Post by ic2 »

Hello Chris,

Thanks for your reply, but selecting text from the program is not the problem; that works.

The problem is that a user can't use cursor movement keys to select text (e.g. Shift-Cursor) or use the cursor keys to scroll up/down through text. That can only be done with the mouse.

Dick
User avatar
Chris
Posts: 4845
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Winforms: how to use cursor keys to select text?

Post by Chris »

Hi Dick,

If that was the case, there would be millions of very angry people throwing their .Net apps out of the Window(s) :)

That does work fine, maybe you have introduced a method intercepting and handling key presses of your textboxes which accidentally "eats" the shift/cursor key presses?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1856
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Winforms: how to use cursor keys to select text?

Post by ic2 »

Hello Chris,
Chris post=25988 userid=313 wrote: If that was the case, there would be millions of very angry people throwing their .Net apps out of the Window(s)
There are many other reasons to do so but still people keep using the .Net apps :lol:

But it seems to work as it should now. Only issue for me is that I have no idea why it didn't earlier....

Dick
Post Reply