Exemplo n.º 1
0
 private void Form2_Load(object sender, EventArgs e)
 {
     //establish a connection using datacontext class
     dc   = new myDatabaseDataContext();
     Emps = dc.Employees.ToList();//data in table is transferred into list
     ShowData();
 }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            myDatabaseDataContext dc = new myDatabaseDataContext();
            //dataGridView1.DataSource = dc.Employees;
            Table <Employee> tab = dc.Employees;

            dataGridView1.DataSource = tab;
        }
Exemplo n.º 3
0
        private void Form3_Load(object sender, EventArgs e)
        {
            dc = new myDatabaseDataContext();
            //var tab = from E in dc.Emps select E;
            //dataGridView1.DataSource = tab;
            //straighwaya bind to grid view
            dataGridView1.DataSource = from E in dc.Emps select E;
            var tab = from E in dc.Emps select new { E.Job };

            comboBox1.DataSource    = tab.Distinct();
            comboBox1.DisplayMember = "Job";
            comboBox1.SelectedIndex = -1;//no selection
            flag = true;
        }