Search code examples
c#winformsdevexpressxtragridgridcontrol

DevExpress select text range within a TextEdit repositoryItem cell of a GridControl


Does anybody know how to select a text range within a TextEdit repositoryItem cell of a GridControl?

The the following code it select the whole text of the cell:

gvMemoryMap.FocusedRowHandle = 4;
gvMemoryMap.FocusedColumn = gvMemoryMap.VisibleColumns[1];
gvMemoryMap.ShowEditor();
gvMemoryMap.ActiveEditor.SelectAll();

But I would like to select a text range as well as someTextBox.Select(2,5) does in the Winforms control.


Solution

  • I got DevExpress thread that meet same requirement as you do. Check the modified code as per your requirement and follow the following approach.

    Cast your ActiveEditor to DevExpress.XtraEditors.TextEdit and you are able to work as you do on TextEdit Control.

    gvMemoryMap.FocusedRowHandle = 4;
    gvMemoryMap.FocusedColumn = gvMemoryMap.VisibleColumns[1];
    gvMemoryMap.ShowEditor();
    (gvMemoryMap.ActiveEditor as DevExpress.XtraEditors.TextEdit).Select(0, 1);
    

    It is tested and working.. Hope this help..