Click here to Skip to main content
15,908,015 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to identify whether or not a control object has been instantiated... [modified] Pin
new_phoenix21-Oct-06 9:28
new_phoenix21-Oct-06 9:28 
GeneralRe: How to identify whether or not a control object has been instantiated... Pin
Guffa21-Oct-06 11:56
Guffa21-Oct-06 11:56 
QuestionForm Updating within Loops Pin
Jethro6321-Oct-06 6:06
Jethro6321-Oct-06 6:06 
AnswerRe: Form Updating within Loops Pin
User 665821-Oct-06 6:41
User 665821-Oct-06 6:41 
GeneralRe: Form Updating within Loops Pin
Jethro6321-Oct-06 19:19
Jethro6321-Oct-06 19:19 
QuestionHow to make an number only text box? Pin
Ming Luo21-Oct-06 5:50
Ming Luo21-Oct-06 5:50 
AnswerRe: How to make an number only text box? Pin
User 665821-Oct-06 6:44
User 665821-Oct-06 6:44 
AnswerRe: How to make an number only text box? Pin
3Dizard21-Oct-06 10:12
3Dizard21-Oct-06 10:12 
Greeeg is definitely right, but I'd prefer a slightly different way than using exception. Here's the code:
<br />
private void AmountBox_KeyPress(object sender, KeyPressEventArgs e)<br />
        {<br />
            switch (e.KeyChar)<br />
            {<br />
                case '0':<br />
                    break;<br />
                case '1':<br />
                    break;<br />
                case '2':<br />
                    break;<br />
                case '3':<br />
                    break;<br />
                case '4':<br />
                    break;<br />
                case '5':<br />
                    break;<br />
                case '6':<br />
                    break;<br />
                case '7':<br />
                    break;<br />
                case '8':<br />
                    break;<br />
                case '9':<br />
                    break;<br />
                default:<br />
                    e.Handled = true;<br />
                    break;<br />
            }<br />
        } 

Setting Handled to true prevents the input from being processed further and that is exactly what you want for anything else than numbers. BTW: This is a function for the KeyPress event.

Greetings
GeneralRe: How to make an number only text box? Pin
Martin2323-Oct-06 0:18
Martin2323-Oct-06 0:18 
Questionhow to Genarate report ??? Pin
iyoko21-Oct-06 5:38
iyoko21-Oct-06 5:38 
Questionhow retrieve data from Cookie?? Pin
iyoko21-Oct-06 5:36
iyoko21-Oct-06 5:36 
AnswerRe: how retrieve data from Cookie?? Pin
Guffa21-Oct-06 6:51
Guffa21-Oct-06 6:51 
GeneralRe: how retrieve data from Cookie?? Pin
iyoko21-Oct-06 22:43
iyoko21-Oct-06 22:43 
QuestionNetwork System.Net.Dns.GetHostByAddress is too slow Pin
bradsnobar20-Oct-06 21:55
bradsnobar20-Oct-06 21:55 
AnswerRe: Network System.Net.Dns.GetHostByAddress is too slow Pin
User 665820-Oct-06 23:43
User 665820-Oct-06 23:43 
QuestionHow to safely raname a vs 2005 project Pin
_marsim_20-Oct-06 21:17
_marsim_20-Oct-06 21:17 
Questione of godgames Pin
ammoh20-Oct-06 21:14
ammoh20-Oct-06 21:14 
QuestionRe: e of godgames Pin
ammoh20-Oct-06 21:21
ammoh20-Oct-06 21:21 
AnswerRe: e of godgames Pin
Vega0221-Oct-06 17:07
Vega0221-Oct-06 17:07 
AnswerRe: e of godgames Pin
LongRange.Shooter23-Oct-06 4:36
LongRange.Shooter23-Oct-06 4:36 
Questiondouble buffering in child controls Pin
ssoffline20-Oct-06 21:05
ssoffline20-Oct-06 21:05 
Questionrecord sound Pin
rzvme20-Oct-06 20:25
rzvme20-Oct-06 20:25 
AnswerRe: record sound Pin
mav.northwind20-Oct-06 21:07
mav.northwind20-Oct-06 21:07 
QuestionTransparency with Windows buttons without flicker Pin
Andreas8820-Oct-06 13:57
Andreas8820-Oct-06 13:57 
QuestionHow to replace multiple spaces in a string to single space. Pin
jerry_pendergraft20-Oct-06 11:58
jerry_pendergraft20-Oct-06 11:58 

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.