protected override bool AllowTextChange(string currentText, NSRange changedRange, string replacementText, string result) { if (result.Length == 0) { return(true); } // If the user backspaced, allow the change to go through. if (replacementText.Length == 0) { if (autocompleted) { // If we've auto-completed and the user backspaces, then he/she is probably entering a name we haven't seen before. backspaced = true; } return(true); } for (int i = 0; i < replacementText.Length; i++) { if (replacementText[i] == '%' || replacementText[i] == '*') { return(false); } } if (AutoComplete && result.Length > 0 && !backspaced) { // Try to auto-complete the safety pilot from the list of known safety pilots matching the provided text var matches = LogBook.GetMatchingSafetyPilots(result); if (matches != null) { // If we've only got 1 match, auto-complete for the user. if (matches.Count == 1) { autocompleted = true; Value = matches[0]; return(false); } // Figure out the maximum amount of matching text so that we can complete up to that far... int maxLength = matches[0].Length; for (int i = 1; i < matches.Count; i++) { int n; for (n = 0; n < Math.Min(matches[i].Length, maxLength); n++) { if (matches[0][n] != matches[i][n]) { break; } } if (n < maxLength) { maxLength = n; } } Value = matches[0].Substring(0, maxLength); autocompleted = true; return(false); } } return(base.AllowTextChange(currentText, changedRange, replacementText, result)); }