コード例 #1
0
        // Order has changed, need to be reflected in the header struture
        public void ReorganizeHeader()
        {
            int i = 0;

            foreach (DataGridViewColumn col in _theDataGrid.Columns)
            {
                string colName      = col.Name;
                string colNameIndex = _theDataGrid.Columns[i++].Name;
            }

//            CCellHeaderVector tCurrentCellHeaderVector = _theMatrix._cellHeaderVector;
            CCellHeaderVector tCellHeaderVector = new CCellHeaderVector();

            i = 0;
            foreach (DataGridViewColumn col in _theDataGrid.Columns.OfType <DataGridViewColumn>().OrderBy(x => x.DisplayIndex))
            {
                string colName      = col.Name;
                string colNameIndex = _theDataGrid.Columns[i++].Name;

                CCellHeader tCellHeader = _theMatrix._cellHeaderVector.GetCellHeaderByColName(colName);

                tCellHeaderVector.AddCellHeader(tCellHeader);
            }

            // replace witht the new one
            _theMatrix._cellHeaderVector = tCellHeaderVector;
        }
コード例 #2
0
        private void LoadDatagrid_Header(DataGridView pDataGrid, string pFileName)
        {
            _theMatrix._cellHeaderVector = CCellHeaderVector.Load(pFileName);

            pDataGrid.Columns.Clear();

            AddCellToGrid(pDataGrid, _theMatrix._cellHeaderVector);
        }
コード例 #3
0
        private void AddCellToGrid(DataGridView pGrid, CCellHeaderVector pCellHeaderVector)
        {
            pGrid.Columns.Clear();

            foreach (CCellHeader bCellHeader in pCellHeaderVector._cellHeaders)
            {
                string tColName   = bCellHeader._name;
                string tColHeader = bCellHeader._header;

                pGrid.Columns.Add(tColName, tColHeader);
            }
        }
コード例 #4
0
        private void SaveDatagrid_Data(DataGridView pDataGrid, string pFileName)
        {
            CCellMatrix       theMatrix         = BuildMatrixFromGrid(pDataGrid);
            CCellHeaderVector tCellHeaderVector = _theMatrix._cellHeaderVector;

            _theMatrix = theMatrix;
            _theMatrix._cellHeaderVector = tCellHeaderVector;


            CCellMatrixIO matrixIO = new CCellMatrixIO();

            matrixIO.BuildMatrixIO(_theMatrix);
            matrixIO.Save(pFileName);
        }
コード例 #5
0
        public void RebuildMatrix()
        {
            // back the headerVector
            CCellHeaderVector tCellHeaderVector = _theMatrix._cellHeaderVector;

            // back the matrix description
            string _matrixPhysicalName          = _theMatrix._matrixPhysicalName;
            string _matrixInheritedPhysicalName = _theMatrix._matrixInheritedPhysicalName;
            string _matrixDescription           = _theMatrix._matrixDescription;
            bool   _isInherited = _theMatrix._isInherited;

            // Build the new matrix from the grid
            _theMatrix = BuildMatrixFromGrid();

            // set back the headerVector
            _theMatrix._cellHeaderVector = tCellHeaderVector;

            // set back the matrix description
            _theMatrix._matrixPhysicalName          = _matrixPhysicalName;
            _theMatrix._matrixInheritedPhysicalName = _matrixInheritedPhysicalName;
            _theMatrix._matrixDescription           = _matrixDescription;
            _theMatrix._isInherited = _isInherited;
        }
コード例 #6
0
        // add cols dynagrids
        private void buttonAddField_Click(object sender, EventArgs e)
        {
            //this.dataGridViewDyn.Columns.Add("newColumnName", "Column Name in Text");

            this.dataGridViewDyn.Rows.Clear();
            this.dataGridViewDyn.Columns.Clear();

            CCellHeader newCellHeader1 = new CCellHeader(1, "col1", "header1", "Descr1", "script1");
            CCellHeader newCellHeader2 = new CCellHeader(2, "col2", "header2", "Descr2", "script2");
            CCellHeader newCellHeader3 = new CCellHeader(3, "col3", "header3", "Descr3", "script3");
            CCellHeader newCellHeader4 = new CCellHeader(4, "col4", "header4", "Descr4", "script4");
            CCellHeader newCellHeader5 = new CCellHeader(5, "col5", "header5", "Descr5", "script5");


            CCellHeaderVector _cellHeaderVector = new CCellHeaderVector();

            _cellHeaderVector.AddCellHeader(newCellHeader1);
            _cellHeaderVector.AddCellHeader(newCellHeader2);
            _cellHeaderVector.AddCellHeader(newCellHeader3);
            _cellHeaderVector.AddCellHeader(newCellHeader4);
            _cellHeaderVector.AddCellHeader(newCellHeader5);

            AddCellToGrid(dataGridViewDyn, _cellHeaderVector);
        }
コード例 #7
0
        public CCellMatrix BuildMatrixFromGrid()
        {
            // back the headerVector
            CCellHeaderVector tCellHeaderVector = _theMatrix._cellHeaderVector;

            // back the new matrix
            CCellMatrix theMatrix = new CCellMatrix();

            // back the headerVector
            theMatrix._cellHeaderVector = tCellHeaderVector;

            CCellVector theCellVector;


            int i_row = 0;
            int i_col = 0;

            foreach (DataGridViewRow row in _theDataGrid.Rows)
            {
                theCellVector = new CCellVector();

                i_col = 0;

                bool last_empty_line = true;

                foreach (DataGridViewCell gridCell in row.Cells)
                {
                    string colName = _theMatrix.ColumnsHeader[i_col]._name;

                    // check if the last row is completely empty in order to insert the vector
                    // see also comment after the foreach loop
                    if (!(gridCell.Value is null))
                    {
                        last_empty_line = false;
                    }

                    CCell cellToInsert;

                    if (gridCell.Tag is null)
                    {
                        string cell_value = (string)gridCell.Value;
                        cellToInsert = new CCell(cell_value, i_row);

                        cellToInsert._cellHeader = _theMatrix.ColumnsHeader[i_col];
                    }
                    else
                    {
                        cellToInsert = (CCell)gridCell.Tag;
                    }

                    theCellVector.Add(colName, cellToInsert);

                    i_col++;
                }

                // in the row is not empty it is added
                if (!last_empty_line)
                {
                    theMatrix.AddVector(i_row, theCellVector);
                }


                i_row++;
            }

            return(theMatrix);
        }