Currently, this can be achieve with this code: TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; bool updating = false; void radTextBox1_TextChanging(object sender, TextChangingEventArgs e) { if (!updating) { int pos = radTextBox1.TextBoxElement.TextBoxItem.SelectionStart; updating = true; radTextBox1.Text = textInfo.ToTitleCase(radTextBox1.Text); radTextBox1.TextBoxElement.TextBoxItem.SelectionStart = pos; updating = false; } }
Thank you for your input Michael. I will pass it along to the team and we will look into it.
The above example is not right. You should be using TextChanged event instead. Otherwise, first letter only capitalizes when you press 2nd letter. I've created my own control by inheriting RadTextBoxControl. This seems to be very simple, why Telerik is not adding this features? public class MidexProperTextBox : RadTextBoxControl { private bool _Updating = false; public MidexProperTextBox() : base() { TextChanged += MidexProperTextBox_TextChanged; } private void MidexProperTextBox_TextChanged(object sender, EventArgs e) { if (!_Updating) { int pos = TextBoxElement.SelectionStart; _Updating = true; Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Text); TextBoxElement.SelectionStart = pos; _Updating = false; } } }
Another approach is: CultureInfo.CurrentCulture.TextInfo.ToTitleCase("hello world"); More information here: http://stackoverflow.com/questions/72831/how-do-i-capitalize-first-letter-of-first-name-and-last-name-in-c