Şimdi Ara

RadioButton eklemek

Bu Konudaki Kullanıcılar:
1 Misafir - 1 Masaüstü
5 sn
3
Cevap
0
Favori
493
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • Herkese merhaba,

    Bir hesap makinesi projesi yazmistim odev icin ama simdi bu projeye RadioButton eklemem gerekli. Denedim ama bir turlu beceremedim. Nasil + - * / operator butonlarini GroupBox icindeki RadioButton dugmelerine cevirebilirim? Simdiden tesekkurler.

    public partial class frmHesapMakinesi : Form 
    {
    public frmHesapMakinesi()
    {
    InitializeComponent();
    }

    private void IslemiSec(object sender, System.EventArgs e)
    {

    Button btnIslem = (Button)sender;
    string Islem = btnIslem.Text;

    try
    {
    if (IsValidData())
    {
    double sayi1 = Convert.ToDouble(txtsayi1.Text);
    double sayi2 = Convert.ToDouble(txtsayi2.Text);
    double sonuc = Hesapla(sayi1, Islem, sayi2);
    sonuc = Math.Round(sonuc, 4);
    this.lblsonuc.Text = sonuc.ToString();
    }
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message + "\n\n" + ex.GetType().ToString() + "\n" +
    ex.StackTrace, "Exception");
    txtsayi2.Focus();
    }
    }

    private double Hesapla(double sayi1, string Islem, double sayi2)
    {
    double sonuc = 0;



    switch (Islem)
    {
    case "+":
    sonuc = sayi1 + sayi2;
    break;
    case "-":
    sonuc = sayi1 - sayi2;
    break;
    case "*":
    sonuc = sayi1 * sayi2;
    break;
    case "/":
    if (sayi2 == 0)
    throw new Exception("Gecersiz islem. Sifira bolemezsiniz!");
    else
    sonuc = sayi1 / sayi2;
    break;
    default:
    break;
    }
    return sonuc;

    }

    public bool IsValidData()
    {
    return
    // Validate the Score text box
    Validator.IsPresent(txtsayi1, "Operand 1") &&
    Validator.IsDouble(txtsayi1, "Operand 1") &&
    Validator.IsWithinRange(txtsayi1, "Operand 1", 0, 1000000) &&
    // Validate the sayi2 text box
    Validator.IsPresent(txtsayi2, "Operand 2") &&
    Validator.IsDouble(txtsayi2, "Operand 2") &&
    Validator.IsWithinRange(txtsayi2, "Operand 2", 0, 1000000);
    }


    private void btnExit_Click(object sender, System.EventArgs e)
    {
    this.Close();
    }


    private void Clearsonuc(object sender, System.EventArgs e)
    {
    this.lblsonuc.Text = "";
    }
    }







  • up
  • up
  • 
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.