JTaylor
2014-04-10T17:05:56Z
I have set up one of my grids to go into edit mode automatically whenever one enters a cell and to be able to use the Tab and Arrow Keys (Up and Down) to move from cell to cell. This, obviously, eliminates the need to press some key to go into edit mode. What I haven't figured out is how to keep it from selecting the contents of the cell. Moving the cursor to the end or beginning of the contents would be fine. Ideally if one clicked on the cell with the mouse the cursor would be placed at that point but that is probably asking too much.

How can I automatically deselect the content and/or place the cursor at a specific point in the content?

Thanks.

Jim
Igor/10Tec
2014-04-11T07:43:55Z
If you double-click a cell or press ENTER to start editing, the whole cell text is selected automatically. FYI: if you press an alpha-numeric key to start editing, the cell text is replaced with it or the pressed char is appended to the cell text depending on the value of the KeyPressBehaviour property, and the caret is placed automatically at the end of the edited text.

Most likely, you use the RequestEditCurCell method without specifying its only parameter to start editing, which is equivalent to double-click or ENTER. However, you can adjust the selection (caret position) after the editing has been started but before the user is able to enter new text in the TextEditStarted event. For instance, to place the caret at the end of the edited text, use event handler like this:

Private Sub grdCust_TextEditStarted()
   grdCust.TextEditSelStart = Len(grdCust.TextEditText)
End Sub

Quote:

Ideally if one clicked on the cell with the mouse the cursor would be placed at that point but that is probably asking too much.



Theoretically this can be also done using the described approach, but the main problem is how to determine the caret position in the text clicked in in the cell. Sure, this can be solved using a lot of API calls, but obviously, this is too much for this task.
JTaylor
2014-04-11T16:27:56Z
This fixes the problem with everything being selected but, assuming I understand what you said, it does not work that way. What it does tells it where to start highlighting text. The cursor is still at the end of the text. If I enter a cell for editing and press the left arrow I am always starting from the end of the text. Maybe that would be a good addition to the Grid. A "TextEditStart(cursor_position, highlight_enum)" method which would allow a person to place the cursor where one wanted when entering edit mode. Some consideration on how to handle the selected text range would need to be given. Maybe highlight=0 None; 1 = TextEditSelStart value to cursor_position (If TextEditSelStart is greater than cursor_position then hightlighting would go from cursor to that position); 2 = Cursor to End of Text. I'll also post this in suggestions.

Thanks again. This solves my immediate problem.

Jim