adige81 Posted May 7, 2013 Share Posted May 7, 2013 selamun aleykum textboxa ben sadece 4 tane rakam girilmesini istiyorum onu nasıl nerden ayarlıyoduk acaba yardım edebilirmisiniz?? Quote Link to comment Share on other sites More sharing options...
WolfmanTR_ Posted May 7, 2013 Share Posted May 7, 2013 konu başlığını düzenler misiniz ? (C# Textbox'a maksimum 4 karakter girmek) gibi Quote Link to comment Share on other sites More sharing options...
sefas Posted May 7, 2013 Share Posted May 7, 2013 textbox özelliklerinde 32000 bir yer var orayı 4 yaparsan 4 karakterden fazlasını girmez Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted May 7, 2013 Editor Share Posted May 7, 2013 textBox2.MaxLength = 5; kodu ile belirttiğiniz sayıda kadar karakter almasını sağlayabilirsiniz. Yada properties kısmından http://prntscr.com/13ue59 buradaki degeri değiştirerek yapabilirsiniz. Quote Link to comment Share on other sites More sharing options...
adige81 Posted May 7, 2013 Author Share Posted May 7, 2013 sağolun çok teşekkürler ilginiz için :) Quote Link to comment Share on other sites More sharing options...
cumman Posted May 7, 2013 Share Posted May 7, 2013 Pairs senin dedigin tum karakterler icin. Sadece rakam kabul etmesini istiyorsan her tusa basildiginda kontrol etmen gerekli. EGer bununla ugrasmak istemiyorsan numericupdown toolu var onu kullanabilirsin. NumbericUpDown.Minimum = -10; NumericUpDown.Maximum = 10; Bununla maximum ve minimumunu kontrol edebilirsin. Yok ille de ben textbox kullanacam ve textboxta rakam harici kabul ettirmeyecem ve maksimum 4 hane olacak dersen. Page_Load una textbox.maxlength=4; dersin textbox keypress eventine textBox1_KeyPress eklersin asagidaki kodu yazarsin. Her klavyeye bastiginda onun rakam olup olmadigin kontrol eder. private void textBox1_KeyPress(object sender, KeyPressEventArgs e){ if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.') { e.Handled = true; } // only allow one decimal point if (e.KeyChar == '.' && (sender as TextBox).Text.IndexOf('.') > -1) { e.Handled = true; } } Bana soracak olursan numericupdown kullanmak daha akillica sonucta sadece rakam girmek istiyorsun ve kodlamada basit her zaman en iyisidir. Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted May 7, 2013 Editor Share Posted May 7, 2013 Pairs senin dedigin tum karakterler icin. Sadece rakam kabul etmesini istiyorsan her tusa basildiginda kontrol etmen gerekli. EGer bununla ugrasmak istemiyorsan numericupdown toolu var onu kullanabilirsin. NumbericUpDown.Minimum = -10; NumericUpDown.Maximum = 10; Bununla maximum ve minimumunu kontrol edebilirsin. Yok ille de ben textbox kullanacam ve textboxta rakam harici kabul ettirmeyecem ve maksimum 4 hane olacak dersen. Page_Load una textbox.maxlength=4; dersin textbox keypress eventine textBox1_KeyPress eklersin asagidaki kodu yazarsin. Her klavyeye bastiginda onun rakam olup olmadigin kontrol eder. private void textBox1_KeyPress(object sender, KeyPressEventArgs e){ if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.') { e.Handled = true; } // only allow one decimal point if (e.KeyChar == '.' && (sender as TextBox).Text.IndexOf('.') > -1) { e.Handled = true; } } Bana soracak olursan numericupdown kullanmak daha akillica sonucta sadece rakam girmek istiyorsun ve kodlamada basit her zaman en iyisidir. Rakam kısmını okumamıştım :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.