Header Ads

C# පාඩම 04 (RadioButton & Combobox)

අද අපි ඔයාලට අරගෙන ආවෙ කොහොමද Radio Button, ComboBox, DateTimePicker වගේ Tools පාවිච්චි කරන්නෙ කියලා. ඉතිං මේ දේවල් පාවිච්චි කරලා ඔයාලට ඉස්සරහට ඕනෙම විදිහෙ Software එකක් නිර්මාණය කරන්න පුළුවන්. ඒ වගේම ඉස්සරහට ඒ Tools පාවිච්චි කරලා ඔයාලට  Database වලට Data Save  කරන හැටිත් කියලා දෙන්න අපි බලාපොරොත්තු වෙනවා. එහෙනම්  Video එක බලලා ඔයාලගෙ අදහස් එහෙමත් දාන්න අමතක කරන්න එපා...









අද වැඩේ සම්පූර්ණ Source Code එක....

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 MobileSurvey
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btn_Show_Click(object sender, EventArgs e)
        {
            string name = txt_Name.Text;
            lbl_Name.Text = name.ToString();


            int age = DateTime.Today.Year - dateTimePicker1.Value.Year;
            lbl_age.Text = age.ToString();


            if (rb_male.Checked == true)
            {
                lbl_gen.Text = "Male";
            }
            else if (rb_female.Checked == true)
            {
                lbl_gen.Text = "Female";
            }

            else {
                MessageBox.Show("Select Your Gender");
            }

            if (cmb_Brand.SelectedIndex == 0)
            {
                lbl_Brand.Text = "Apple";
            }

            else if (cmb_Brand.SelectedIndex == 1)
            {
                lbl_Brand.Text = "Samsung";
            }
            else if (cmb_Brand.SelectedIndex == 2)
            {
                lbl_Brand.Text = "Sony";
            }
            else if (cmb_Brand.SelectedIndex == 3)
            {
                lbl_Brand.Text = "HTC";
            }
            else if (cmb_Brand.SelectedIndex == 4)
            {
                lbl_Brand.Text = "Huawei";
            }

            else
            {
                MessageBox.Show("Please Select Your Brand");
            }
        }
    }

}

1 comment:

  1. Don't use old VB style naming anymore please

    ReplyDelete

Powered by Blogger.