Click here to Skip to main content
15,925,602 members
Home / Discussions / C#
   

C#

 
QuestionDirectX? Pin
Muammar©4-Sep-07 1:31
Muammar©4-Sep-07 1:31 
QuestionCheck for Numeric value Pin
nagendrathecoder4-Sep-07 1:03
nagendrathecoder4-Sep-07 1:03 
AnswerRe: Check for Numeric value Pin
originSH4-Sep-07 1:14
originSH4-Sep-07 1:14 
GeneralRe: Check for Numeric value Pin
VenkataRamana.Gali4-Sep-07 1:32
VenkataRamana.Gali4-Sep-07 1:32 
GeneralRe: Check for Numeric value Pin
originSH4-Sep-07 1:39
originSH4-Sep-07 1:39 
GeneralRe: Check for Numeric value Pin
Gopal.S4-Sep-07 2:23
Gopal.S4-Sep-07 2:23 
GeneralRe: Check for Numeric value Pin
Pete O'Hanlon4-Sep-07 2:32
mvePete O'Hanlon4-Sep-07 2:32 
GeneralRe: Check for Numeric value Pin
Gopal.S4-Sep-07 2:59
Gopal.S4-Sep-07 2:59 
Hi,

Thanks for your reply.

I was checked only integer value. You can check "." and other special characters seperatly for double value.

Here is code snippet for double value:

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
TextBox txtBox = sender as TextBox;

if (e.KeyChar == '\b') { return; }

if (Char.IsDigit(e.KeyChar))
{
string amount = txtBox.Text;
int pos = txtBox.Text.IndexOf('.');

if ((pos > 0) & (amount.Length > 10))
{
e.Handled = true;
return;
}

if ((pos == -1) & (amount.Length > 7))
{
e.Handled = true;
return;
}

if ((pos > 0) & (txtBox.SelectionStart > pos))
{
amount = amount.Substring(pos, amount.Length - pos);
if (amount.Length > 2)
e.Handled = true;
}
else
e.Handled = false;
}
else if (e.KeyChar == '.')
{
if (txtBox.Text.IndexOf('.') > 0)
e.Handled = true;
}
else
e.Handled = true;

}


This code support eight integer value and two decimal digits.

Please let me know this will help for you.

Thanks,
S.Gopal.

Gopal.S

GeneralRe: Check for Numeric value Pin
originSH4-Sep-07 3:24
originSH4-Sep-07 3:24 
GeneralRe: Check for Numeric value Pin
Gopal.S4-Sep-07 4:01
Gopal.S4-Sep-07 4:01 
QuestionTry to define string in Resources.resx with \n but ,NET see this as \\n Pin
Yanshof4-Sep-07 0:45
Yanshof4-Sep-07 0:45 
QuestionDropdown column in Datagrid Pin
André Stroebel4-Sep-07 0:41
André Stroebel4-Sep-07 0:41 
AnswerRe: Dropdown column in Datagrid Pin
André Stroebel4-Sep-07 2:56
André Stroebel4-Sep-07 2:56 
QuestionCancel from Custom Installer Pin
vSoares4-Sep-07 0:30
professionalvSoares4-Sep-07 0:30 
QuestionHow to copy all listbox items to cipboard? Pin
Abelinda814-Sep-07 0:26
Abelinda814-Sep-07 0:26 
AnswerRe: How to copy all listbox items to cipboard? Pin
Colin Angus Mackay4-Sep-07 1:49
Colin Angus Mackay4-Sep-07 1:49 
GeneralRe: How to copy all listbox items to cipboard? Pin
Abelinda814-Sep-07 4:36
Abelinda814-Sep-07 4:36 
GeneralRe: How to copy all listbox items to cipboard? Pin
Colin Angus Mackay4-Sep-07 5:03
Colin Angus Mackay4-Sep-07 5:03 
Questionremoving event handlers Pin
JoZ CaVaLLo4-Sep-07 0:09
JoZ CaVaLLo4-Sep-07 0:09 
AnswerRe: removing event handlers Pin
originSH4-Sep-07 0:11
originSH4-Sep-07 0:11 
QuestionActive Directory Pin
dorine824-Sep-07 0:01
dorine824-Sep-07 0:01 
AnswerRe: Active Directory Pin
Dave Kreskowiak4-Sep-07 5:39
mveDave Kreskowiak4-Sep-07 5:39 
QuestionI'm going crazy! C# operators Pin
Eli Nurman3-Sep-07 23:48
Eli Nurman3-Sep-07 23:48 
AnswerRe: I'm going crazy! C# operators Pin
Muammar©3-Sep-07 23:57
Muammar©3-Sep-07 23:57 
GeneralRe: I'm going crazy! C# operators Pin
originSH4-Sep-07 0:01
originSH4-Sep-07 0:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.