Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Editors (TextBox, MaskedEdit, SpinEditor, BrowseEditor, ColorBox) > Some Shortcut Keys not working in RadTextBox

Not answered Some Shortcut Keys not working in RadTextBox

Feed from this thread
  • Alan avatar

    Posted on Jan 31, 2012 (permalink)

    Ctrl+A (Select All)
    Ctr+Y (Redo)
    are not working in RadText Boxes.
    Also, is there a way to change the undo being  done in RadTextBoxes to be a character at a time.

    Reply

  • Stefan Stefan admin's avatar

    Posted on Feb 2, 2012 (permalink)

    Hi Alan,

    Thank you for writing.

    Indeed, RadTextBox currently does not support redo operation. However, undo and select all are available and the undo functionality works exactly the way the standard MIcrosoft text box does. Your suggestions for the redo operation and for the undo per character functionality are quite reasonable and this is why I will add them as feature requests in our PITS system. At the following links, you can add your vote for these requests:

    Meanwhile, please refer to the following snippet, which demonstrates how to achieve the desired behavior with a stack:
    public partial class Form1 : Form
    {
        Stack<string> undoStack = new Stack<string>();
        Stack<string> redoStack = new Stack<string>();
     
        public Form1()
        {
            InitializeComponent();
     
            radTextBox1.TextChanged += new EventHandler(radTextBox1_TextChanged);
            radTextBox1.KeyDown += new KeyEventHandler(radTextBox1_KeyDown);
            undoStack.Push(radTextBox1.Text);
     
        }
     
        bool preventUpdate = false;
     
        void radTextBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.Y && redoStack.Count > 0)
            {
                radTextBox1.Text = redoStack.Pop();
            }
            if (e.Control && e.KeyCode == Keys.Z && undoStack.Count > 0)
            {
                string str = undoStack.Pop();
                int caretPosition = radTextBox1.SelectionStart;
     
                redoStack.Push(str);
                preventUpdate = true;
                radTextBox1.Text = str;
                radTextBox1.SelectionStart = caretPosition;
                preventUpdate = false;
            }
        }
     
        void radTextBox1_TextChanged(object sender, EventArgs e)
        {
            radTextBox1.ClearUndo();
            if (!preventUpdate)
            {
                RadTextBox textBox = (RadTextBox)sender;
                undoStack.Push(radTextBox1.Text);
            }
        }
    }

    I hope that the provided information addresses your question. Your Telerik points have been updated for this feature request.
     
    Greetings,
    Stefan
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Editors (TextBox, MaskedEdit, SpinEditor, BrowseEditor, ColorBox) > Some Shortcut Keys not working in RadTextBox
Related resources for "Some Shortcut Keys not working in RadTextBox"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]