private void selectWord() { try { int cursorPosition = this.SelectionStart - 1; if (cursorPosition >= 0) { int nextSpace = this.Text.IndexOf(' ', cursorPosition); int selectionStart = 0; string trimmedString = string.Empty; if (nextSpace != -1) { trimmedString = this.Text.Substring(0, nextSpace); } else { trimmedString = this.Text;//.Substring(cursorPosition); } if (trimmedString.LastIndexOf(' ') != -1) { selectionStart = 1 + trimmedString.LastIndexOf(' '); trimmedString = trimmedString.Substring(1 + trimmedString.LastIndexOf(' ')); } _selWord = trimmedString; } } catch (Exception ex) { Logger.D(AppGlobals.PyGetTraceback(ex)); } }