I'm using a TextBox in a CellEditing template in a GridView for entering data.
The requirement is that we make sure that when someone clicks into the grid to edit, the data that is already in the text box be selected. Always. Always. The text should ALWAYS be selected when entering edit mode. We NEVER want to see the cursor until at least one new key is hit (arrow key, or other). The text should always be selected.
So I implemented some changes to the text box as outlined here:
http://stackoverflow.com/questions/660554/how-to-automatically-select-all-text-on-focus-in-wpf-textbox
That should in theory work for always selecting the text box.
However, I've found that the Grid View column, when going into edit mode, always UNSELECTS the selection if you click directly on the middle of the text. In other words, it gives me a cursor and no text selection.
Debugging into this, I've found that the culprit comes from one of the GridViewColumn classes calling "PlaceCaretOnTextBox". I want to avoid this.
Is there a setting in the column where I can get it to stop killing the selected text when entering edit mode?
Thanks,
Chad Lehman
20th Century Fox
The requirement is that we make sure that when someone clicks into the grid to edit, the data that is already in the text box be selected. Always. Always. The text should ALWAYS be selected when entering edit mode. We NEVER want to see the cursor until at least one new key is hit (arrow key, or other). The text should always be selected.
So I implemented some changes to the text box as outlined here:
http://stackoverflow.com/questions/660554/how-to-automatically-select-all-text-on-focus-in-wpf-textbox
That should in theory work for always selecting the text box.
However, I've found that the Grid View column, when going into edit mode, always UNSELECTS the selection if you click directly on the middle of the text. In other words, it gives me a cursor and no text selection.
Debugging into this, I've found that the culprit comes from one of the GridViewColumn classes calling "PlaceCaretOnTextBox". I want to avoid this.
Is there a setting in the column where I can get it to stop killing the selected text when entering edit mode?
Thanks,
Chad Lehman
20th Century Fox