Sabtu, 11 Januari 2014

array

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

        private void button1_Click(object sender, EventArgs e)
        {
            int[] a = new int[5];

            a[0] = 1;
            a[1] = 2;
            a[2] = 3;
            a[3] = 4;
            a[4] = 5;
           
            for (int i = 0; i < 5; i++)
            {
                listBox1.Items.Add(a[i]);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int[,] b = new int[2, 3];

            b[0,0] = 1;
            b[0,1] = 2;
            b[0,2] = 3;
            b[1,0] = 4;
            b[1,1] = 5;
            b[1,2] = 6;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    listBox2.Items.Add(b[i, j]);
                }
            }
        }
    }
}


Jumat, 10 Januari 2014

C# Enable and Disable

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

        private void button1_Click(object sender, EventArgs e)
        {
            label1.Enabled = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            label1.Enabled = false;
        }
    }
}
http://reionnote.wordpress.com/belajar-c-kode/belajar-c-sharp-enable-disable/