private void comboBox3_SelectedIndexChanged(object sender, EventArgs e) { ComboBox cb = (ComboBox)sender; Base_Form baseForm = new Base_Form(); BookLoad_Form bookLoad2 = new BookLoad_Form(); if (cb.SelectedIndex == 0) { UserControl7 userControl = new UserControl7(); panel2.Controls.Add(userControl); comboBox3.Visible = false; dgv.DataSource = userControl.dataGridView1.DataSource; DataTable dt = GetDataTableFromDGV(dgv); ds.Tables.Add(dt); ds.WriteXml(File.OpenWrite(@"D:\eclipse\git\C-Sharp_2020_2\XMLFile1.xml")); MessageBox.Show("데이터를 XML파일로 저장했습니다!!!!"); } else if (cb.SelectedIndex == 1) { UserControl7 userControl = new UserControl7(); panel2.Controls.Add(userControl); comboBox3.Visible = false; bookLoad2.ShowDialog(); bookLoad2.Location = new Point(200, 200); } }
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { ComboBox cb = (ComboBox)sender; Base_Form baseForm = new Base_Form(); BookLoad_Form bookLoad1 = new BookLoad_Form(); BookLoad_Form bookLoad3 = new BookLoad_Form(); if (cb.SelectedIndex == 0) { UserControl7 userControl = new UserControl7(); panel2.Controls.Add(userControl); comboBox2.Visible = false; bookLoad1.ShowDialog(); bookLoad1.Location = new Point(200, 200); } else if (cb.SelectedIndex == 1) { UserControl7 userControl = new UserControl7(); panel2.Controls.Add(userControl); comboBox2.Visible = false; ds.ReadXml(@"D:\eclipse\git\C-Sharp_2020_2\XMLFile1.xml"); dgv.DataSource = ds.Tables[0]; userControl.dataLoad(dgv); MessageBox.Show("XML파일의 데이터를 가져왔습니다!!!!"); } else if (cb.SelectedIndex == 2) { UserControl7 userControl = new UserControl7(); panel2.Controls.Add(userControl); comboBox2.Visible = false; bookLoad3.ShowDialog(); bookLoad3.Location = new Point(200, 200); } }