Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            SqlCommand cmd = new SqlCommand("SELECT * FROM Categories", conn);

            conn.Open();
            SqlDataReader okuyucu = cmd.ExecuteReader();


            if (okuyucu.HasRows)
            {
                while (okuyucu.Read())
                {
                    KategoriSinif ks = new KategoriSinif();
                    ks.CategoryID   = okuyucu[0].ToString();
                    ks.CategoryName = okuyucu[1].ToString();
                    ks.Description  = okuyucu[2].ToString();
                    listBox1.Items.Add(ks);
                }
            }
            else
            {
                MessageBox.Show("Kayıt Bulunamadı");
            }
            conn.Close();
        }
Ejemplo n.º 2
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            KategoriSinif ks = (KategoriSinif)listBox1.SelectedItem;

            label1.Text = ks.Description;
        }