Approved
Last Updated: 15 Aug 2017 09:33 by ADMIN
ADMIN
Stefan
Created on: 17 Aug 2012 07:05
Category: Editors
Type: Feature Request
4
ADD. RadTextBox - create new CharacterCasting option that will make each word's first letter a capital letter
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;
            }
        }
3 comments
ADMIN
Stefan
Posted on: 14 Nov 2016 10:56
Thank you for your input Michael. I will pass it along to the team and we will look into it.
Michael
Posted on: 10 Nov 2016 18:37
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;
            }
        }
    }
ADMIN
Peter
Posted on: 05 Sep 2016 12:57
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