to make textbox to allow decimal values in textbox in c#.net windows forms.
private void txtRate_KeyPress(object sender, KeyPressEventArgs e){ if (!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar) && !(e.KeyChar.Equals('.')))
e.Handled =true;}
---------------------------VB.NET-------------------------------
Dim decexist As Boolean = False
If (CType(sender, TextBox).Text.IndexOf(".") > 0) And e.KeyChar.Equals("."c) Then
decexist = True
End If
If (Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) And Not (e.KeyChar.Equals("."c))) Or decexist Then
e.Handled = True
End If
allow decimal values in textbox in c#.net windows forms.
Posted by
Rajesh Rolen
at
Monday, April 6, 2009
0 comments:
Post a Comment