Rabu, 25 September 2013

Belajar ASP.NET 4

Posted by Xiuxiu on 19.54 with No comments
1.Buat Project baru, pilih Windows Forms Application, beri nama FormVal, Location tempatkan di folder pelajaran Anda, Solution pilih Add to Solution (tidak membuat solution baru).

2. Tambahkan beberapa Component dari ToolBox -> All Windows Forms -> Label, TextBox, Button, ProgressBar, ErrorProvider -> Beri nama masing-masing Component seperti contoh dibawah ini: Drag dan Drop Component yang sudah dipilih ke atas Form dan Atur tata letak masing-masing Component.

3. Setelah itu kasih background. terserah kamu
Untuk BackColor Label dapat diberi warna transparant agar menyatu dengan backgroundImage Form.
4. Lalu ketikan Script seperti di bawah
ini scripnya:
namespace FormVal
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
           
        }
        private void textBox2_TextChanged(object sender, EventArgs e)
        {
        }
        private void Form1_Load(object sender, EventArgs e)
        {
        }
        private void progressBar1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            bar1.Value = 0;
            if (a.Text == "")
            {
                x.SetError(a, "Masukkan Nama");
            }
            else
            {
                x.SetError(a, "");
            }
            if (b.Text == "")
            {
                x1.SetError(b, "Masukan NIS");
            }
            else
            {
                x1.SetError(b, "");
            }
            if (c.Text == "")
            {
                x2.SetError(c, "Masukan Kelas");
            }
            else
            {
                x2.SetError(c, "");
            }
            if (d.Text == "")
            {
                x3.SetError(d, "Masukan SMP Asal");
            }
            else
            {
                x3.SetError(d, "");
            }
            for (int i = 0; i < bar1.Maximum; i++)
            {
                bar1.Value = bar1.Value + 1;
            }
            if (a.Text == "" || b.Text == "" || c.Text == "" || d.Text == "")
            {
                MessageBox.Show("Anda Belum Lengkap Mengisi Data");
            }
            else
            {
                MessageBox.Show("\nNama\t : " + a.Text + "\nNIM\t : "
            + b.Text + "\nKelas\t : " + c.Text + "\nShift\t : " + d.Text);
            }

        }
        private void bar1_Click(object sender, EventArgs e)
        {

        }
    }
}

5.Lalu tekan Ctrl+F5 atau run. berikut tampilanya
6. Jika data belum lengkap, maka tampilan seperti berikut :
SILAHKAN MENCOBA :)


0 komentar:

Posting Komentar