Tutorial #3 – Pizza Order in C#
Here is my new pizza order tutorial for you. In this tutorial you are able to control checkboxes and radiobuttons together and show them into a message box window.
Codes below…
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class pizza : Form
{
//Some global strings to keep radiobutton and checkbox events text's.
private String a1 = null;
private String a2 = null;
private String a3 = null;
private String menu = null;
public pizza()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// This event for new order button, so it makes everything null.
textBox1.Text = null;
textBox2.Text = null;
radioButton1.Checked = false;
radioButton2.Checked = false;
radioButton3.Checked = false;
checkBox1.Checked = false;
checkBox2.Checked = false;
checkBox3.Checked = false;
}
private void button3_Click(object sender, EventArgs e)
{
Application.Exit(); // it used for exit button
}
private void button2_Click(object sender, EventArgs e)
{
String name = textBox1.Text;
String surname = textBox2.Text;
MessageBox.Show("Name: " + name + "\nSurname: " + surname + "\nMenu: " + menu + "\nAdditions:" + a1 + a2 + a3, "Confirm Your Order!", MessageBoxButtons.YesNo ,MessageBoxIcon.Information);
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
a1 = " Mushroom";
}
else
{
a1 = null;
}
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
if (checkBox2.Checked)
{
a2 = " Olive";
}
else
{
a2 = null;
}
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
if (checkBox3.Checked)
{
a3 = " Corn";
}
else
{
a3 = null;
}
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
menu = "Classic";
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
menu = "Full";
}
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
menu = "Vegeterian";
}
}
}
Any questions ?
Tweet
Thanks for dropping by! Feel free to join the discussion by leaving comments, and stay updated by subscribing to the

Bu linkteki sözlerini tutmanı istiyorum
1- lütfen türkçe olsun 2- microsoft’a ve teknolojilerine hayır
blog yayını yaptığını bilmiyordum bundan sonra düzenli olarak uğrayacağım mekanlardan birtanesi seninkisi olacak..