Click here to Skip to main content
15,922,584 members
Home / Discussions / C#
   

C#

 
GeneralRe: finding Movie duration of a wmv file Pin
sreejith ss nair15-Sep-04 3:54
sreejith ss nair15-Sep-04 3:54 
GeneralRe: finding Movie duration of a wmv file Pin
gupta vaibhav15-Sep-04 18:18
gupta vaibhav15-Sep-04 18:18 
GeneralRe: finding Movie duration of a wmv file Pin
sreejith ss nair15-Sep-04 22:24
sreejith ss nair15-Sep-04 22:24 
GeneralRe: finding Movie duration of a wmv file Pin
gupta vaibhav15-Sep-04 22:45
gupta vaibhav15-Sep-04 22:45 
GeneralOnly 2 decimal places for data in a textbox Pin
myNameIsRon14-Sep-04 17:07
myNameIsRon14-Sep-04 17:07 
GeneralRe: Only 2 decimal places for data in a textbox Pin
KevinMac14-Sep-04 18:22
KevinMac14-Sep-04 18:22 
GeneralRe: Only 2 decimal places for data in a textbox Pin
myNameIsRon14-Sep-04 19:09
myNameIsRon14-Sep-04 19:09 
GeneralRe: Only 2 decimal places for data in a textbox Pin
sreejith ss nair14-Sep-04 18:34
sreejith ss nair14-Sep-04 18:34 
hi,

For your first requirement you can use this logic on keypress event of your textbox control.
This won't take any value which is not of the numeric type.


private void txtbox_KeyPress_1(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
try
{
if (Char.IsDigit(e.KeyChar))
e.Handled=false;
else
e.Handled=true;
}
catch(Exception Ex)
{
MessageBox.Show("Invalid Entry Found","Error Description",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}



And your next requirement is not professional in nature. According to me, here you are trying to force the user to do this much. You need to know one thing we can't force the user to do something that we expect. Our software need to make his life simpler. (This is only my humble suggection. And it is upto you to deside what you want.)

Why don't you do onething, after getting the user input try to format it as what ever format you want. Here is the logic for that.



textBox1.Text=Convert.ToString(float.Parse(textBox1.Text).ToString("#,##.##"));

**************************
S r e e j i t h N a i r
**************************
GeneralRe: Only 2 decimal places for data in a textbox Pin
myNameIsRon14-Sep-04 19:03
myNameIsRon14-Sep-04 19:03 
GeneralRe: Only 2 decimal places for data in a textbox Pin
sreejith ss nair14-Sep-04 19:10
sreejith ss nair14-Sep-04 19:10 
GeneralRe: Only 2 decimal places for data in a textbox Pin
Stefan Troschuetz15-Sep-04 0:19
Stefan Troschuetz15-Sep-04 0:19 
GeneralRe: Only 2 decimal places for data in a textbox Pin
myNameIsRon15-Sep-04 18:24
myNameIsRon15-Sep-04 18:24 
General#define Pin
gmhanna14-Sep-04 16:33
gmhanna14-Sep-04 16:33 
GeneralRe: #define Pin
sreejith ss nair14-Sep-04 18:39
sreejith ss nair14-Sep-04 18:39 
GeneralRe: #define Pin
mav.northwind14-Sep-04 19:53
mav.northwind14-Sep-04 19:53 
GeneralRe: #define Pin
mebmer 12345678914-Sep-04 21:50
mebmer 12345678914-Sep-04 21:50 
GeneralHANDLE Pin
eggie514-Sep-04 14:39
eggie514-Sep-04 14:39 
GeneralRe: HANDLE Pin
Colin Angus Mackay14-Sep-04 14:56
Colin Angus Mackay14-Sep-04 14:56 
QuestionHow to change the text of a text object at runtime in crystal reports for .NET (C#) Pin
Member 119488414-Sep-04 11:45
Member 119488414-Sep-04 11:45 
AnswerRe: How to change the text of a text object at runtime in crystal reports for .NET (C#) Pin
sreejith ss nair14-Sep-04 18:42
sreejith ss nair14-Sep-04 18:42 
AnswerRe: How to change the text of a text object at runtime in crystal reports for .NET (C#) Pin
Member 119488414-Sep-04 20:08
Member 119488414-Sep-04 20:08 
Generalaccessing listbox items on a form from another class Pin
mr spoon14-Sep-04 10:20
mr spoon14-Sep-04 10:20 
GeneralRe: accessing listbox items on a form from another class Pin
Heath Stewart14-Sep-04 11:45
protectorHeath Stewart14-Sep-04 11:45 
GeneralRe: accessing listbox items on a form from another class Pin
mr spoon15-Sep-04 10:23
mr spoon15-Sep-04 10:23 
GeneralStored Procedures with C# Pin
Member 131560014-Sep-04 9:47
Member 131560014-Sep-04 9:47 

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.