We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

KeyPress in IntegerTextBox

Thread ID:

Created:

Updated:

Platform:

Replies:

26866 Apr 1,2005 11:03 PM UTC Apr 5,2005 04:03 PM UTC WinForms 3
loading
Tags: Tools
Paul
Asked On April 1, 2005 11:03 PM UTC

I want to make an IntegerTextBox read only. But using the ReadOnly property disables all the nice color coding (Red for negative) I like. So I want to keep it ReadOnly = false, and ignore keystrokes. I tried to install a KeyPress handler, but it looks like NumberTextBoxBase ignores the e.Handled = true returned from my handler. How can I achieve this?

Administrator [Syncfusion]
Replied On April 4, 2005 04:30 PM UTC

Hi Paul, IntegerTextBox handles the keyboard input in it''s OnKeyPress method. So you''ll want to extend IntegerTextBox and override OnKeyPress as demonstrated by the following code snippet: public class ReadOnlyIntegerTextBox : IntegerTextBox { public ReadOnlyIntegerTextBox() : base() { } protected override void OnKeyPress(KeyPressEventArgs e) { return; } } This will prevent OnKeyPress from doing anything. Please let me know if you have any further questions on this subject. Regards, Gregory Austin Syncfusion Inc.

Paul
Replied On April 5, 2005 03:19 PM UTC

I did what you said. My OnKeyPress does get called, but the problem is the caller, NumberTextBoxBase:ProcessKeyEventArgs does not alter his behavior in any way, based on the outcome of OnKeyPress. The callback is just an aside, not a participant in outcome determination.

Administrator [Syncfusion]
Replied On April 5, 2005 04:03 PM UTC

Hi Paul, May be overriding the ProcessCmdKey without calling the base class and returning true will give you the result you''re are looking for. Regards, Thomas

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;