public void ImportListTest_UnequalColumns() { _TestSingleTon.Instance._SetupForLayoutPanelTests(); Form form = new Form(); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); form.Controls.Add(panel); // needed else DataGrid does not initialize form.Show(); form.Visible = false; //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout("mynewpanel", true, null); NoteDataXML_Table test = new NoteDataXML_Table(425, 380); test.GuidForNote = "thisguid1"; test.Caption = "note1"; panel.SaveLayout(); string[] newData = new string[3] { "1,col2,col3", "2,col2,col3", "3,col2,col3" }; TableWrapper.ImportList(newData, (DataTable)test.dataSource); panel.SaveLayout(); List <string> values = test.GetValuesForColumn(1, "*"); Assert.AreEqual(3, values.Count); Assert.AreEqual("1,col2,col3", values[0]); form.Dispose(); }
/// <summary> /// will import a listof entries into the table /// /// December 2008. /// /// Changing this to be csv format /// r1c1, r1c2, r1c3 /// r2c1, r2c2, r2c3 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ImportListClick(object sender, EventArgs e) { TablePanel_Form_ImportList fList = new TablePanel_Form_ImportList(); if (fList.ShowDialog() == DialogResult.OK) { TableWrapper.ImportList(fList.textList.Lines, (DataTable)dataGrid1.DataSource); } }
// private DataSet DATA_SOURCE() // { // if (panelTable == null) // { // return appearance.dataSource; // } // else // { // return panelTable.dataSource; // } //} protected void EditColumns() { // changing columns can destroy data // pick columns form_StringControl addColumn = new form_StringControl(MainFormBase.MainFormIcon); addColumn.Strings = GetJustColumnNames(); int beforelength = addColumn.Strings.Length; int afterlength = 0; if (addColumn.ShowDialog() == DialogResult.OK) { // February 2012 - copying to clipboard to try to save data /* * 1. Don't bother copying, just build and store a string in memory * 2. If *FEWER* Columns then we do not bother copying (too hard) * 3. If *MORE* Columns then we need to add extra commas at end * 4. We need to remove the Table1 and column name lines */ afterlength = addColumn.Strings.Length; string sOldData = ""; // we do not import table if we have removed columns if (afterlength >= beforelength) { try { sOldData = TableToString((DataTable)dataGrid1.DataSource, true, (afterlength - beforelength)); lg.Instance.Line("TablePanel->ButtonEditCOlumns", ProblemType.MESSAGE, sOldData, Loud.CTRIVIAL); } catch (Exception ex) { NewMessage.Show(ex.ToString()); } } else { lg.Instance.Line("TablePanel->EditColumns", ProblemType.MESSAGE, "we do not import table if we have removed columns"); } ColumnDetails[] newColumns = new ColumnDetails[addColumn.Strings.Length]; for (int i = 0; i < addColumn.Strings.Length; i++) { newColumns[i] = new ColumnDetails(addColumn.Strings[i], defaultwidth); } //Cols = addColumn.Strings; dataGrid1.DataSource = null; dataGrid1.DataSource = BuildTableFromColumns(newColumns); if ("" != sOldData) { string[] list = sOldData.Split(new string[1] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); try { // panelTable.ImportList(list); TableWrapper.ImportList(list, (DataTable)dataGrid1.DataSource); } catch (Exception ex) { NewMessage.Show(ex.ToString()); } } } }