Exemplo n.º 1
0
        private void LoadDSMonAn(ListView lsvMonAn, string maLoai)
        {
            List <MonDTO> ls = MonBUS.LayDSMonAnTheoLoai(maLoai);

            for (int i = 0; i < ls.Count; i++)
            {
                ListViewItem lvi = new ListViewItem(ls[i].TenMon);
                lvi.SubItems.Add(ls[i].MaMon);
                lvi.SubItems.Add(ls[i].DonGia.ToString());
                lvi.SubItems.Add(ls[i].HinhAnh);
                if (File.Exists("image\\" + ls[i].HinhAnh))
                {
                    byte[]       byteHA = File.ReadAllBytes("image\\" + ls[i].HinhAnh);
                    MemoryStream ms     = new MemoryStream(byteHA);
                    Image        img    = Image.FromStream(ms);
                    imlMonAn.Images.Add(img);
                    lvi.ImageIndex = imlMonAn.Images.Count - 1;
                }
                lsvMonAn.Items.Add(lvi);
            }
        }