David
Tue Jan 29 05:28:24 CST 2008
Jayesh wrote:
> On Jan 28, 1:46 pm, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
>> There is no way to do this. Usally you would override the OnKeyPress
>> protected method in a derived TextBox class or simply subscribe to the
>> KeyPress event of the TextBox class and handle key input as required. Check
>> for numerics etc if data is allowed bubble back up to the base class.
>> --
>> Simon Hart
>> Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com
>>
>> "Anthony Davis" wrote:
>>
>>> I have an application that runs on Windows CE and Windows Mobile (5.0+
>>> for both) and has text fields that require numeric data only for some
>>> fields and mixed numeric/text for others.
>>> When the focus is on a text input that is numeric only, is there a way
>>> that I can programmatically set the number lock button to on so that
>>> the keys that are usually text are numbers?
>
> Hi,
> You can copy this code and just wire up this event handler to your
> textbox and you are done.
> protected void NumericTextBox_KeyPress(Object sender,
> KeyPressEventArgs e)
> {
> // Reject anything that isn't a number character or an
> editting command
> if ( !(Char.IsDigit(e.KeyChar) || Char.IsControl(e.KeyChar)) )
> {
> e.Handled = true;
> return;
> }
> }
>
> Thanks,
> Jayesh Modha
That doesn't stop text being pasted into the textbox though.
D