Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

Mulitline textbox AcceptsReturn not working.

$
0
0
I've updated jen's code to resolve the issue as follows:

        public override List<DelegateCommandWrapper> ProvideCommandsForKey(KeyEventArgs args)
        {
            List<DelegateCommandWrapper> actionsToExecute = base.ProvideCommandsForKey(args);

            if (args.Key == Key.Enter)
            {
                if (args.OriginalSource is TextBox && (args.OriginalSource as TextBox).AcceptsReturn)
                {
                    TextBox textBox = args.OriginalSource as TextBox;

                    actionsToExecute.Clear();

                    StringBuilder stringBuilder = new StringBuilder(textBox.Text);
                    stringBuilder.Insert(textBox.SelectionStart, Environment.NewLine); // add new line
                    textBox.Text = stringBuilder.ToString();

                    textBox.SelectionStart += 3; // move cursor to new line
                    textBox.Focus();
                }
                else
                {
                    actionsToExecute.Clear();
                    actionsToExecute.Add(new DataFormDelegateCommandWrapper(RadDataFormCommands.CommitEdit, this.DataForm));
                }
            }

            return actionsToExecute;
        }

Viewing all articles
Browse latest Browse all 94857

Trending Articles