- namespace WindowsFormsApplication3 {
- public partial class MyCarsForm1: {
- public MyCarsForm1() {
- InitializeComponent();
- cmbSelectCar.Items.Add("Auston MartinDB11");
- }
-
- interface IDB11 {
- void DB11Specifications();
- }
-
- public class AustonMartin: MyCarsForm1,
- IDB11 {
-
- void IDB11.DisplaySpecifications() {
- DataSet ds = new DataSet();
- DataTable dt1 = new DataTable();
- string c = @ "Data Source=.; Initial Catalog=master; Integrated Security=True";
- SqlConnection con = new SqlConnection(c);
- con.Open();
- string query = "select * from AustonMartinDB11 ";
- SqlCommand cmd = new SqlCommand(query, con);
- SqlDataAdapter da = new SqlDataAdapter(cmd);
-
- da.Fill(ds, query);
- dgvSpecifications.DataSource = ds;
- }
- }
-
-
- private void cmbSelectCar_SelectedIndexChanged(object sender, EventArgs e) {
- IDB11 am = new AustonMartin();
- am.DisplaySpecifications();
- if (cmbSelectCar.SelectedIndex == 0) {
- am.DisplaySpecifications();
- }
- }
- }
- }
// On selecting first index of the combobox, it is displaying empty datagridview.
// On checking by the break point, it is loading the data in the datagridview.