8 Mayıs 2015 Cuma

C# Diziye Veri Kaydetme Verileri Gösterme



6 tane textbox 3 ü kayıt diğer 3 ü göstermek için 2 buton(kaydetmek ve göstermek için)
Kodlar;


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;
using System.Collections;

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

          ArrayList isim = new ArrayList(); 
        ArrayList soyisim = new ArrayList();
        ArrayList sınıf = new ArrayList();
        int i = 0,j=0;
        bool gizle = false;


        private void button1_Click(object sender, EventArgs e)
        {

            isim.Add(textBox1.Text);

            soyisim.Add(textBox2.Text);
            sınıf.Add(textBox3.Text);
            i++;
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";

        }



        private void button2_Click(object sender, EventArgs e)
        {
            if (gizle == false)
            {
                groupBox1.Visible = true;
                button5.Visible = true;
                button4.Visible = true;

                textBox4.Text = isim[j].ToString();
               textBox5.Text = soyisim[j].ToString();
                textBox6.Text = sınıf[j].ToString();
                gizle = true;
                button2.Text = "Gizle";
            }
            else
            {
                gizle = false;
                groupBox1.Visible = false;
                button5.Visible = false;
                button4.Visible = false;
                textBox4.Text = "";
                textBox5.Text = "";
                textBox6.Text = "";
                button2.Text = "Görüntüle";
            }

        }

        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                textBox4.Text = isim[j].ToString();
                textBox5.Text = soyisim[j].ToString();
                textBox6.Text = sınıf[j].ToString();
                j++;
            }
            catch (Exception)
            {
                MessageBox.Show("Zaten Son Veri Görüntüleniyor");
            }
          
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (j > 0)
            {
                j--;
                textBox4.Text = isim[j].ToString();
                textBox5.Text = soyisim[j].ToString();
                textBox6.Text = sınıf[j].ToString();

            }
            else MessageBox.Show("Zaten İlk Veri Görüntüleniyor!");
        }
    }
}