private void btnprofile_Click(object sender, EventArgs e) { var frmprf = new frmProfile(); foreach (DataGridViewColumn dc in DGV1.Columns) { // frmprf.lbxPrimary.Items.Add(dc.HeaderText); if (!frmprf.lbxSecondary.Items.Contains(dc.HeaderText)) { frmprf.lbxPrimary.Items.Add(dc.HeaderText); } } if (frmprf.ShowDialog() == DialogResult.OK) { foreach (DataGridViewColumn dc in DGV1.Columns) { this.DGV1.Columns[dc.HeaderText.Replace(" ", "")].Visible = true; } String GetProfileName = frmprf.GetProfileName(); DataSet ds = new DataSet(); ds.ReadXml(Application.StartupPath + Path.DirectorySeparatorChar + "Profiles" + Path.DirectorySeparatorChar + GetProfileName + ".xml"); if (ds.Tables.Count == 0) { return; } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string st = ds.Tables[0].Rows[i]["Input"].ToString(); this.DGV1.Columns[ds.Tables[0].Rows[i]["Input"].ToString().Replace(" ","")].Visible = false; } } else { String GetProfileName = frmprf.GetProfileName(); DataSet ds = new DataSet(); ds.ReadXml(Application.StartupPath + Path.DirectorySeparatorChar + "Profiles" + Path.DirectorySeparatorChar + "MarketCol.xml"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string st = ds.Tables[0].Rows[i]["Input"].ToString(); this.DGV1.Columns[ds.Tables[0].Rows[i]["Input"].ToString().Replace(" ", "")].Visible = true; } } }
private void btnprofile_Click(object sender, EventArgs e) { var frmprf = new frmProfile(); foreach (DataGridViewColumn dc in DGV.Columns) { frmprf.lbxPrimary.Items.Add(dc.HeaderText); //if (!frmprf.lbxSecondary.Items.Contains(dc.HeaderText)) //{ // frmprf.lbxPrimary.Items.Add(dc.HeaderText); // this.DGV.Columns[dc.HeaderText].Visible = false; //} //else //{ // this.DGV.Columns[dc.HeaderText].Visible = true; //} } if (frmprf.ShowDialog() == DialogResult.OK) { GetProfileName = frmprf.GetProfileName(); LoadDgcOlumns(Application.StartupPath +Path.DirectorySeparatorChar+ "Profiles" + Path.DirectorySeparatorChar + GetProfileName + ".xml"); } }