コード例 #1
0
        public Form1()
        {
            InitializeComponent();
            db = new HerbsContext();
            db.Herbs.Load();
            dataGridView1.DataSource = db.Herbs.Local.ToBindingList();
            List <Herbs> herbs = db.Herbs.ToList();

            this.listHerbs.DataSource    = herbs;
            this.listHerbs.ValueMember   = "Id";
            this.listHerbs.DisplayMember = "Name";
        }
コード例 #2
0
 private void ButtonSearch_Click(object sender, EventArgs e)
 {
     try
     {
         HerbsContext db   = new HerbsContext();
         string       name = textBox2.Text;
         Herbs        Hb   = db.Herbs.Single(hb => hb.Name == name);
         this.textBox3.Text     = Hb.Description;
         this.pictureBox1.Image = ConvertBytetoImage(Hb.Photo);
     }
     catch
     {
         MessageBox.Show("Не удалось найти объект");
     }
 }