private void StripOpenFile_Click(object sender, EventArgs e) { DialogResult res = openFileDialog.ShowDialog(); if (res == DialogResult.OK) { DataFile.ReadXml(openFileDialog.FileName); CmbTests.Text = DataFile.Rows[0][5].ToString(); foreach (DataRow FileRow in DataFile.Rows) { for (int i = 0; i < DG.Rows.Count; i++) { if (DG.Rows[i].Cells[1].Value.ToString() == FileRow[0].ToString()) { DG.Rows[i].Cells[0].Value = "True"; DG.Rows[i].Cells[2].Value = FileRow[1].ToString(); DG.Rows[i].Cells[3].Value = FileRow[2].ToString(); DG.Rows[i].Cells[4].Value = FileRow[3].ToString(); DG.Rows[i].Cells[5].Value = FileRow[4].ToString(); } } } DG.EndEdit(); } }
private void StripSaveFile_Click(object sender, EventArgs e) { DialogResult res = saveFileDialog.ShowDialog(); if (res == DialogResult.OK) { DG.EndEdit(); DataFile.Clear(); DataFile.Rows.Add(null, null, null, null, null, CmbTests.Text); for (int i = 0; i < DG.Rows.Count; i++) { if (DG.Rows[i].Cells[0].Value.ToString() == "True") { DataFile.Rows.Add(DG.Rows[i].Cells[1].Value.ToString(), DG.Rows[i].Cells[2].Value.ToString(), DG.Rows[i].Cells[3].Value.ToString(), DG.Rows[i].Cells[4].Value.ToString(), DG.Rows[i].Cells[5].Value.ToString()); } } DataFile.WriteXml(saveFileDialog.FileName); } }