void LoadDB(string fileName) { LiteDatabase db = new LiteDatabase(fileName); var cols = db.GetCollectionNames(); Text = fileName; tabControl1.TabPages.Clear(); foreach (var colName in cols) { var tabPage = new TabPage(colName); var tb = new DataTable(); foreach (var doc in db.GetCollection(colName).FindAll()) { if (tb.Columns.Count == 0) tb.Columns.AddRange(doc.Keys.Select(key => new DataColumn(key) { Caption = key }).ToArray()); var row = tb.NewRow(); foreach (var item in doc.Keys) { row[item] = doc[item]; } tb.Rows.Add(row); } var dg = new DataGridView(); dg.DataSource = tb; dg.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dg.Dock = DockStyle.Fill; tabPage.Controls.Add(dg); tabControl1.TabPages.Add(tabPage); } foreach (var item in comboBox1.Items) { if (item.ToString() == fileName) return; } comboBox1.Items.Add(fileName); saveHistory(); }