A simple way to add basic masked-edit features to your CF controls is to
edit the
keypress and keydown events to enforce the rules you want. For example,
let's
say we have a textbox called txtZipCode where we want to enforce that only
numeric
characters may be entered. You can do this:
_private bool _nonNumberEntered;
private void txtZipCode_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
if (_nonNumberEntered == true)
e.Handled = true;
}
private void txtZipCode_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
_nonNumberEntered = false;
if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9)
if (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9)
if(e.KeyCode != Keys.Back)
_nonNumberEntered = true;
}
--
Darren Shaffer
Principal Architect
Connected Innovation
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Chris,
> I was looking for a masked editbox on the web when I chance upon your
> entry. Would it be possible for you to email me your control too?
> Thanks in advance.
>
> Dylan.
>
> chris-s wrote:
>> I've got one I can email you if you wish.
>>
>> Chris.
>>
>>
>> "n2alexan" <(E-Mail Removed)> wrote in message
>> news:4d7d01c325f6$e6123000$(E-Mail Removed)...
>> > Hi,
>> > I am looking for a mask Edit control to validate user
>> > entry.
>> > I want the user to be able to enter number with specified
>> > decimal places after the point.
>> > I have managed to use Regular Expression and Text Box to
>> > validate the entry. However, Mask Edit Control would be an
>> > ideal solution. Does this control exits in CF? Or could
>> > anyone give an advise where I can find customised text box
>> > control.
>> > thank you
>> > Nataliya
>
|