C# Form Radiobutton ve Checkbox Nesneleri Kullanımı Örneği - Bilişim Konuları

C# Form Radiobutton ve Checkbox Nesneleri Kullanımı Örneği

Bu örneğimizde C# form ortamında Radiobutton ve Checkbox nesnelerinin kullanımıyla ilgili ortak bir program yapacağız. Programda iki tane radiobutton nesnesi ve üç tane de checkbox nesnesi bulunmaktadır. Bunlardan başka iki tane textbox nensesi ve label etiketleri de bulunmaktadır. Kullanıcının adı soyadı cinsiyeti ve seçtiği dersler bilgileri girildikten sonra bu bilgiler alt tarafta iki tane etiket üzerine kontrol edilerek yazdırılıyor. Bu örnekteki amaç birden fazla radyo buton nesnesini ve onay kutusu nesnesini if komutu kullanarak kontrol etmektir.

C# program kodları:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        //www.bilisimkonulari.com
        private void button1_Click(object sender, EventArgs e)
        {
            string Ad, Soyad;
            string Cinsiyet = null;
            string Dersler = null;

            Ad = textBox1.Text;
            Soyad = textBox2.Text;

            if (radioButton1.Checked == true)
            {
                Cinsiyet = "Bay ";
            }
            else if (radioButton2.Checked == true)
            {
                Cinsiyet = "Bayan ";
            }
            if (checkBox1.Checked == true)
            {
                Dersler = Dersler + " Matematik ";
            }
            if (checkBox2.Checked == true)
            {
                Dersler = Dersler + " Fizik ";
            }
            if (checkBox3.Checked == true)
            {
                Dersler = Dersler + " Kimya ";
            }

            label1.Text = Cinsiyet + Ad + " " + Soyad;
            label5.Text = Dersler + " Seçtiniz";
        }
    }
}

Programın ekran görüntüleri:




csharp-radio-checkbox4

csharp-radio-checkbox3

csharp-radio-checkbox2

csharp-radio-checkbox1

Bu Yazıya Tepkin Nedir?
+1
1
+1
0
+1
0
+1
0
+1
1
+1
1
+1
0

<< Önceki Yazı

Sonraki Yazı >>

Yorum Yap

1 Yorum