using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ETSRK.Frome
{
    public partial class frmStudent : Form
    {

        BindingSource _bsStudenti=new BindingSource();
        public frmStudent()
        {
            InitializeComponent();
            STUDENTSKA_EFEntities db=new STUDENTSKA_EFEntities();
            _bsStudenti.DataSource = db.students
                .ToList();
            
            lstSpisak.DisplayMember = "";
            lstSpisak.ValueMember = "ID_STUDENTA";
            lstSpisak.FormattingEnabled = true;
            lstSpisak.Format += LstSpisak_Format;

            lstSpisak.DataSource = _bsStudenti;
        }

        private void LstSpisak_Format(object sender, ListControlConvertEventArgs e)
        {
            var s = e.ListItem as student;
            if (s != null) {
                e.Value = $"{s.IME} {s.PREZIME} {s.SMER}-{s.BROJ}/{s.GODINA_UPISA}";
            }
        }
    }
}
