o zaman bütün checkboxları kontrol ettirip yaptırman lazım her if else de
bu sefer bütün kombinasyonlar için teker teker oluşturmam lazım çok kalabalık bir kod yığını olacak daha kestirme bir yolu vardır bence.
Son yapılan işlemi bir yerde tut
int SonislemSira = 0;
void Sonislem()
{
switch (SonislemSira)
{
case 0:
textBox1.Font = new Font(textBox1.Font, textBox1.Font.Style ^ FontStyle.Strikeout);
break;
case 1:
textBox1.Font = new Font(textBox1.Font, textBox1.Font.Style ^ FontStyle.Underline);
break;
case 2:
textBox1.Font = new Font(textBox1.Font, textBox1.Font.Style ^ FontStyle.Italic);
break;
case 3:
textBox1.Font = new Font(textBox1.Font, textBox1.Font.Style ^ FontStyle.Bold);
break;
default:
break;
}
}
private void Checkstrikeout_CheckedChanged(object sender, EventArgs e)
{
if (Checkstrikeout.Checked) { textBox1.Font = new Font(textBox1.Font, textBox1.Font.Style ^ FontStyle.Strikeout); SonislemSira = 0; }
else { Sonislem(); }
}
private void Checkunderline_CheckedChanged(object sender, EventArgs e)
{
if (Checkunderline.Checked) { textBox1.Font = new Font(textBox1.Font, textBox1.Font.Style ^ FontStyle.Underline); SonislemSira = 1; }
else { Sonislem(); }
}
private void Checkitalic_CheckedChanged(object sender, EventArgs e)
{
if (Checkitalic.Checked) { textBox1.Font = new Font(textBox1.Font, textBox1.Font.Style ^ FontStyle.Italic); SonislemSira = 2; }
else { Sonislem(); }
}
private void CheckBold_CheckedChanged(object sender, EventArgs e)
{
if (CheckBold.Checked) { textBox1.Font = new Font(textBox1.Font, textBox1.Font.Style ^ FontStyle.Bold); SonislemSira = 3; }
else { Sonislem(); }
}
Teşekkürler deneyeceğim.
arkadaşın dediğine katılıyorum farklı olarakta eğer checkbox kullanımı zorunlu değilse richtextbox ve font dialog olayına bakabilirsiniz
Maalesef checkbox kullanımı zorunlu