{"id":2862,"date":"2012-05-26T00:42:16","date_gmt":"2012-05-25T15:42:16","guid":{"rendered":"http:\/\/nanoappli.com\/blog\/?p=2862"},"modified":"2012-05-26T00:42:16","modified_gmt":"2012-05-25T15:42:16","slug":"ctextbox%e3%81%ab%e6%95%b0%e5%ad%97%e3%81%ae%e3%81%bf%e5%85%a5%e5%8a%9b%e5%8f%af%e8%83%bd%e3%81%ab%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"http:\/\/nanoappli.com\/blog\/archives\/2862","title":{"rendered":"[C#]TextBox\u306b\u6570\u5b57\u306e\u307f\u5165\u529b\u53ef\u80fd\u306b\u3059\u308b"},"content":{"rendered":"<p>\n\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306f\u3001TextBox\u306b\u5bfe\u3057\u3066\u6570\u5b57\u306e\u307f\u3092\u5165\u529b\u53ef\u80fd\u3068\u3059\u308b\u30b3\u30fc\u30c9\u3067\u3059\u3002<br \/>\n\u6570\u5b57\u4ee5\u5916\u3092\u5165\u529b\u3057\u305f\u5834\u5408\u306f\u7121\u8996\u3055\u308c\u307e\u3059\u3002<br \/>\n<pre lang=\"csharp\">\nprivate void textBox1_KeyPress( object sender, KeyPressEventArgs e ) {\n    \/\/ \u5236\u5fa1\u6587\u5b57\u306f\u5165\u529b\u53ef\n    if ( char.IsControl(e.KeyChar) ) {\n        e.Handled = false;\n        return;\n    }\n\n    \/\/ \u6570\u5b57(0-9)\u306f\u5165\u529b\u53ef\n    if ( char.IsDigit(e.KeyChar)  ) {\n        e.Handled = false;\n        return;\n    }\n\n    \/\/ \u5c0f\u6570\u70b9\u306f\uff11\u3064\u3060\u3051\u5165\u529b\u53ef\n    if ( e.KeyChar == '.') {\n        TextBox target = sender as TextBox;\n        if ( target.Text.IndexOf('.') < 0 ) {\n            \/\/ \u8907\u6570\u306e\u30d4\u30ea\u30aa\u30c9\u5165\u529b\u306fNG\n            e.Handled = false;\n            return;\n        }\n    }\n\n    \/\/ \u4e0a\u8a18\u4ee5\u5916\u306f\u5165\u529b\u4e0d\u53ef\n    e.Handled = true;\n}\n<\/pre>\n<br \/>\n3\u3064\u3081\u306eif\u3067\u3001\u5c0f\u6570\u70b9\u306e\u5165\u529b\u3092\u8a31\u5bb9\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3082\u3057\u3001\u5c0f\u6570\u3092\uff2e\uff27\u3068\u307f\u306a\u3057\u305f\u3044\u5834\u5408\u306f\u30013\u3064\u3081\u306eif\u6587\u81ea\u4f53\u3092\u524a\u9664\u3059\u308c\u3070\u3088\u3044\u3067\u3059\u3002<br \/>\n<br \/>\n\u307e\u305f\u3001\u6570\u5b57(digit)\u3067\u306f\u306a\u304f\u6570\u5024(number)\u306e\u5165\u529b\u3092\u884c\u308f\u305b\u305f\u3044\u5834\u5408\u306f\u3001NumericUpDown\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u304c\u4fbf\u5229\u3067\u3059\u3002\u3053\u3061\u3089\u306f\u3001\u4e0a\u8a18\u306e\u3088\u3046\u306a\u5165\u529b\u5236\u9650\u306b\u52a0\u3048\u3066\u3001\u4e0a\u9650\u5024\uff65\u4e0b\u9650\u5024\u3092\u6307\u5b9a\u3059\u308b\u4e8b\u3082\u53ef\u80fd\u3067\u3059\u3002<br \/>\n<a href=\"http:\/\/nanoappli.com\/blog\/wp-content\/uploads\/2012\/05\/20120526_01.jpg\"><img loading=\"lazy\" src=\"http:\/\/nanoappli.com\/blog\/wp-content\/uploads\/2012\/05\/20120526_01.jpg\" alt=\"\" title=\"20120526_01\" width=\"201\" height=\"354\" class=\"alignnone size-full wp-image-2878\" srcset=\"http:\/\/nanoappli.com\/blog\/wp-content\/uploads\/2012\/05\/20120526_01.jpg 201w, http:\/\/nanoappli.com\/blog\/wp-content\/uploads\/2012\/05\/20120526_01-170x300.jpg 170w\" sizes=\"(max-width: 201px) 100vw, 201px\" \/><\/a><br \/>\n<br \/>\n<br \/>\n<br \/>\n<br \/>\n\u307e\u305f\u3001\u672c\u984c\u304b\u3089\u306f\u5c11\u3057\u5916\u308c\u307e\u3059\u304c\u3001\u6570\u5b57(digit)\u3068\u6570\u5024(number)\u306e\u9055\u3044\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<br \/>\n<br \/>\n\u6570\u5b57\u3068\u3044\u3046\u306e\u306f\u3001\u6570\u3092\u8868\u3059\u6587\u5b57\u3067\u3001\u4f8b\u3048\u3070\u793e\u54e1\u756a\u53f7\u3001\u4f1a\u54e1No\u3001\u4f1d\u7968\u756a\u53f7\u306a\u3069\u3082\u6570\u5b57\u306b\u542b\u307e\u308c\u307e\u3059\u3002<br \/>\n\u3053\u308c\u306b\u5bfe\u3057\u3066\u6570\u5024\u306f\u3001\u91d1\u984d\u3084\u6570\u91cf\u306a\u3069\u306e\u3001\u6570\u5b66\u7684\u306a\u610f\u5473\u3067\u306e\"\u6570\"\u3092\u610f\u5473\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306f\u3001TextBox\u306b\u5bfe\u3057\u3066\u6570\u5b57\u306e\u307f\u3092\u5165\u529b\u53ef\u80fd\u3068\u3059\u308b\u30b3\u30fc\u30c9\u3067\u3059\u3002 \u6570\u5b57\u4ee5\u5916\u3092\u5165\u529b\u3057\u305f\u5834\u5408\u306f\u7121\u8996\u3055\u308c\u307e\u3059\u3002 private void textBox1_KeyPress( object sender, KeyPressEventArgs e ) { \/\/ \u5236\u5fa1\u6587\u5b57\u306f\u5165\u529b\u53ef if ( char.IsControl(e.KeyChar) ) { e.Handled = false; return; } \/\/ \u6570\u5b57(0-9)\u306f\u5165\u529b\u53ef if ( char.IsDigit(e.KeyChar) ) { e.Handled = false; return; } \/\/ \u5c0f\u6570\u70b9\u306f\uff11\u3064\u3060\u3051\u5165\u529b\u53ef if \u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[1],"tags":[97],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":725,"url":"http:\/\/nanoappli.com\/blog\/archives\/725","url_meta":{"origin":2862,"position":0},"title":"[JavaScript]\u6570\u5024\u5165\u529b\u6b04\u3067\u3001\u5168\u89d2\u6570\u5b57\u3084\u66f8\u5f0f\u7de8\u96c6\u3055\u308c\u305f\u6587\u5b57\u3092\u53d7\u3051\u5165\u308c\u308b\u3002(\u5168\u89d2\/\u534a\u89d2\u5909\u63db)","date":"2012\u5e741\u670823\u65e5","format":false,"excerpt":"\u540d\u53e4\u5c4b\u5e02\u306e\u56f3\u66f8\u9928\u306b\u306f\u3001Web\u30b5\u30a4\u30c8\u304c\u3042\u308a\u30aa\u30f3\u30e9\u30a4\u30f3\u3067\u4e88\u7d04\u304c\u51fa\u6765\u308b\u306e\u304c\u4fbf\u5229\u3067\u3059\u3002 \u3044\u3064\u3082\u306e\u3088\u3046\u306b\u5229\u7528\u3057\u2026","rel":"","context":"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/nanoappli.com\/blog\/wp-content\/uploads\/20120123_03-500x336.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":6793,"url":"http:\/\/nanoappli.com\/blog\/archives\/6793","url_meta":{"origin":2862,"position":1},"title":"\u30b5\u30af\u30e9\u30a8\u30c7\u30a3\u30bf\u3067\u5236\u5fa1\u6587\u5b57\u3092\u5165\u529b\u3059\u308b\u65b9\u6cd5","date":"2016\u5e741\u670826\u65e5","format":false,"excerpt":"ASCII\u30b3\u30fc\u30c9\u306b\u306f\u3001\u901a\u5e38\u306e\u6570\u5b57\u3084\u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\u4ee5\u5916\u306bCR,LF,STX,ETX\u306a\u3069\u306e\u5236\u5fa1\u6587\u5b57\u304c\u3042\u308a\u2026","rel":"","context":"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/nanoappli.com\/blog\/wp-content\/uploads\/2016\/01\/20160126_1_1-500x366.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":6719,"url":"http:\/\/nanoappli.com\/blog\/archives\/6719","url_meta":{"origin":2862,"position":2},"title":"[C#]WinForm\u3067\u30b2\u30fc\u30e0\u4f5c\u6210\u6642\u3001\u30ab\u30fc\u30bd\u30eb\u5165\u529b\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5","date":"2016\u5e741\u670819\u65e5","format":false,"excerpt":"Windows\u4e0a\u3067.Net Framework\u3092\u4f7f\u7528\u3057\u3066\u30b2\u30fc\u30e0\u306a\u3069\u3092\u4f5c\u308b\u3068\u304d\u3001\u30ad\u30fc\u5165\u529b\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u2026","rel":"","context":"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3577,"url":"http:\/\/nanoappli.com\/blog\/archives\/3577","url_meta":{"origin":2862,"position":3},"title":"[C\u8a00\u8a9e]printf\u306e\u5f8c\u306e\u5165\u529b\u5f85\u3061\u3067\u5165\u529b\u30d0\u30c3\u30d5\u30a1\u304c\u30af\u30ea\u30a2\u3055\u308c\u308b\u7406\u7531","date":"2012\u5e747\u670812\u65e5","format":false,"excerpt":"C\u8a00\u8a9e\u306e\u5165\u9580\u8005\u5411\u3051\u306b\u66f8\u304b\u308c\u305f\u66f8\u7c4d\u3092\u898b\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u826f\u304f\u6709\u308a\u307e\u3059\u3002 #include \u2026","rel":"","context":"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2130,"url":"http:\/\/nanoappli.com\/blog\/archives\/2130","url_meta":{"origin":2862,"position":4},"title":"[C#]Form.AcceptButton\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001\u8907\u6570\u884cTextBox\u3067\u6539\u884c\u3067\u304d\u306a\u3044\u3002","date":"2012\u5e744\u670811\u65e5","format":false,"excerpt":"Form.AcceptButton\u3067\u3001OK\u6642\u306e\u30dc\u30bf\u30f3\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001MultiLine=true\u306b\u8a2d\u5b9a\u2026","rel":"","context":"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7634,"url":"http:\/\/nanoappli.com\/blog\/archives\/7634","url_meta":{"origin":2862,"position":5},"title":"[C#]Form\u4e0a\u306e\u5168TextBox\u306b\u5bfe\u3057\u3001Ctrl-A\u3067\u5168\u9078\u629e\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u65b9\u6cd5","date":"2016\u5e746\u670827\u65e5","format":false,"excerpt":"VisualStudio\u306b\u3066WinForm\u3092\u4f7f\u7528\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u6642\u3001TextBox\u306b\u5bfe\u3057\u3066Ctr\u2026","rel":"","context":"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/posts\/2862"}],"collection":[{"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/comments?post=2862"}],"version-history":[{"count":3,"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/posts\/2862\/revisions"}],"predecessor-version":[{"id":2880,"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/posts\/2862\/revisions\/2880"}],"wp:attachment":[{"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/media?parent=2862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/categories?post=2862"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/tags?post=2862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}