bool IEditGrid.Edit(System.Data.DataTable tb, GridStyleInfo info, out System.Data.DataTable tb2, out GridStyleInfo info2) { // this.dataGridView1.DataSource = tb.Copy(); this.info = info; // if (this.ShowDialog() == DialogResult.OK) { tb2 = (DataTable)this.dataGridView1.DataSource; info2 = this.info; return(true); } else { tb2 = null; info2 = null; return(false); } }
bool IGridable.EditGrid(string[] fields) { var tb = new DataTable(); IEditGrid edit = new EditGrid(); foreach (string field in fields) { int flag = 0; foreach (DataRow row in tbstyle.Rows) { if (row["colname"].ToString() == field) { flag = 1; } } // if (flag == 0) { DataRow r = tbstyle.NewRow(); tbstyle.Rows.Add(r); r["display"] = false; r["colname"] = field; r["colbyname"] = field; r["width"] = 100; r["align"] = "左"; r["format"] = ""; r["smalltotal"] = false; } } // List <DataRow> lstrow = new List <DataRow>(); foreach (DataRow row in tbstyle.Rows) { string colname = row["colname"].ToString(); int flag = 0; foreach (string field in fields) { if (colname == field) { flag = 1; } } // if (flag == 0) { lstrow.Add(row); } } foreach (DataRow row in lstrow) { tbstyle.Rows.Remove(row); } // GridStyleInfo info2; if (edit.Edit(tbstyle, info, out tb, out info2) == true) { tbstyle = tb; info = info2; this.Refresh(); return(true); } else { return(false); } }