Re: Data Validation in C#

  • From: Jamal Mazrui <empower@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Thu, 29 Apr 2010 19:47:19 -0400

Yes, you can do this by defining a handler for the MaskInputRejected event, explained at


http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.maskinputrejected.aspx

Note that the above URL is long and may have wrapped.

Jamal

On 4/28/2010 6:29 PM, Celia Rodriguez wrote:
Hi Martin,

Thank you for the info.  One more thing, is it possible to issue an error
message when the mask box encounters invalid data?
Thank you,
Celia
-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Martin Slack
Sent: Wednesday, April 28, 2010 8:25 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: Data Validation in C#

Hi Celia,

   If you are using the Visual Studio Express C# IDE, you need to select a
MaskedTextBox from the Toolbox.  When this has been placed on the form, F4
will bring up the properties window, and you look for the property Mask.
Tab across and activate the drop down list, and you will find a number of
different formats for the mask.  If you can find a suitable one, then at
runtime the box will only accept numerical inputs: if you attempt to enter
an alphabetic character, there will just be a beep and nothing extra will
appear in the input, in other words, the component itself does the checking.

   hth

Martin


----- Original Message -----
From: "Celia Rodriguez"<celia-rodriguez@xxxxxxxxxxxxx>
To:<programmingblind@xxxxxxxxxxxxx>
Sent: Wednesday, April 28, 2010 11:28 AM
Subject: Data Validation in C#


Hi Everyone,

I have a very simple question.  I hope someone can help.

If I have a textbox with "0077" and I want to validate this as
alphanumberic
Because I don't want to lose the zeroes.
What would be the best way to do this.
Can I do this in a try/catch block?
Or can I do this in a maskBox and How do I set it up ?

Thank you in advance,


__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: