Arama butonu
Bu konudaki kullanıcılar: 1 misafir
2
Cevap
494
Tıklama
0
Öne Çıkarma
RadioButton eklemek
C
9 yıl
Onbaşı
Konu Sahibi

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 = "";
}
}



C
9 yıl
Onbaşı
Konu Sahibi

C
9 yıl
Onbaşı
Konu Sahibi

up



DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.