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?
ADAdministrator Syncfusion Team April 4, 2005 11:30 AM
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)
This will prevent OnKeyPress from doing anything. Please let me know if you have any further questions on this subject.
PAPaulApril 5, 2005 10:19 AM
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.
ADAdministrator Syncfusion Team April 5, 2005 11:03 AM
May be overriding the ProcessCmdKey without calling the base class and returning true will give you the result you''re are looking for.