コード例 #1
0
ファイル: DbSelection.cs プロジェクト: xibeilang524/AC
        private void cmbDbType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.gbDbConfig.Controls.Count > 0)
            {
                for (int intIndex = 0; intIndex < this.gbDbConfig.Controls.Count; intIndex++)
                {
                    this.gbDbConfig.Controls[0].Dispose();
                }
            }

            DbType dbType = ((ComboBox)sender).SelectedItem as DbType;
            IDb    db     = null;

            if (this.m_Dbs != null)
            {
                foreach (IDb db1 in this.m_Dbs)
                {
                    if (dbType.Type.Equals(db1.GetType()))
                    {
                        db = db1;
                        break;
                    }
                }
            }

            if (db == null)
            {
                db = dbType.CreateDb();
            }

            IDbConfigControl dbConfig = dbType.CreateConfigControl(typeof(System.Windows.Forms.Control));

            dbConfig.SetDb(db);

            Control ctl = dbConfig as Control;

            ctl.Dock = DockStyle.Fill;
            this.gbDbConfig.Controls.Add(ctl);
        }