private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string t = comboBox1.Text; switch (t) { case "TestTable.dbf": //dataGridView1.Visible = false; //dataGridView2.Visible = true; Models.DataService dataService = new Models.DataService(); var test = dataService.Test1(comboBox1.Text); bs.DataSource = test; dataGridView2.DataSource = bs.DataSource; break; case "TestTable1.dbf": dataGridView1.Visible = true; dataGridView2.Visible = false; dataService = new Models.DataService(); test = dataService.Test1(comboBox1.Text); bs.DataSource = test; dataGridView1.DataSource = bs.DataSource; break; } }
BindingSource bs = new BindingSource(); // 資料擊結 private void FileGet_Load(object sender, EventArgs e) { Models.DataService dataService = new Models.DataService(); var test = dataService.Test1(comboBox1.Text); bs.DataSource = test; dataGridView2.DataSource = bs.DataSource; }