TextBox Does Not Fire Events!

2 posts, 0 answers
  1. Onur Tezic
    Onur Tezic avatar
    3 posts
    Member since:
    Sep 2009

    Posted 17 Dec 2009 Link to this post

    Hi All,

    I have created a class which inherits from RADTextBox and override the OnKeyPress() method.

    public class RegExpRadTextBox : RadTextBox
    {
    string _keyRegExp;
    public string KeyRegExp
    {
    get { return this._keyRegExp; }
    set { this._keyRegExp = value; }
    }

    protected override void OnKeyPress(KeyPressEventArgs e)
    {
    if (!string.IsNullOrEmpty(this._keyRegExp))
    {
    if (!Regex.IsMatch(e.KeyChar.ToString(), this._keyRegExp))
    {
    e.Handled = true;
    }
    }

    base.OnKeyPress(e);
    }
    }

    But when i type some text, nothing happens (Keypress Event Firing/Raised).

    (Keydown is also doesnt work.) 

    What should i do? 

    Thanks.

  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 21 Dec 2009 Link to this post

    Hi Onur Tezic,

    Thank you for your question. This happens because we are using a Microsoft TextBox inside RadTextBox. When you press a key, the microsoft text box is focused and it gets the key down / pressed notification, not RadTextBox. You should be able to implement your functionality with the help of TextChanging and TextChanged events that RadTextBox provides.

    Kind regards,
    Victor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top