Пример #1
0
        private string[,] GetSuperScript()
        {
            AUGrid c1FlexGrid1 = this.Grid;
            int    rcount      = c1FlexGrid1.Rows.Count;
            int    ccount      = c1FlexGrid1.Columns.Count;

            string[,] supscr = new string[rcount, ccount];
            string[] colsprscrpt = null;// = new string[rcount];// col of superscripts
            //for (int i = 0; i < rcount; i++) //rows
            //{
            for (int j = 0; j < ccount; j++)     //cols
            {
                //if (c1FlexGrid1[i, j] != null)
                colsprscrpt = c1FlexGrid1.Columns[j].Tag != null ? c1FlexGrid1.Columns[j].Tag as string[]: null;        //c1FlexGrid1[i, j].ToString();
                if (colsprscrpt != null)
                {
                    for (int ri = 0; ri < rcount; ri++)
                    {
                        if (ri < colsprscrpt.Length)    // to avoid index out of bounds. Flexgrid has "total" area outside data range
                        {
                            supscr[ri, j] = colsprscrpt[ri];
                        }
                    }
                }
            }
            //}
            return(supscr);
        }
Пример #2
0
        private string[,] GetGridData()
        {
            AUGrid c1FlexGrid1 = this.Grid;
            int    rcount      = c1FlexGrid1.Rows.Count;
            int    ccount      = c1FlexGrid1.Columns.Count;

            string[,] GData = new string[rcount, ccount];
            for (int i = 0; i < rcount; i++)
            {
                for (int j = 0; j < ccount; j++)
                {
                    if (c1FlexGrid1[i, j] != null)
                    {
                        GData[i, j] = c1FlexGrid1[i, j].ToString();
                    }
                }
            }
            return(GData);
        }
Пример #3
0
        //Now if row/col headers  and data is not provided thru above properties and are populated
        //manually, as we were originally doing. Then we need to read all row/col headers and data
        //from the manually created grid.

        private string[,] GetRowHeaders()
        {
            AUGrid c1FlexGrid1 = this.Grid;
            var    rowheaders  = c1FlexGrid1.RowHeaders;
            int    rcount      = rowheaders.Rows.Count;
            int    ccount      = rowheaders.Columns.Count;

            string[,] RHeaders = new string[rcount, ccount];
            for (int i = 0; i < rcount; i++)
            {
                for (int j = 0; j < ccount; j++)
                {
                    if (rowheaders[i, j] != null)
                    {
                        RHeaders[i, j] = rowheaders[i, j].ToString();
                    }
                }
            }

            return(RHeaders);
        }
Пример #4
0
        private string[,] GetColHeaders()
        {
            AUGrid c1FlexGrid1 = this.Grid;
            var    colheaders  = c1FlexGrid1.ColumnHeaders;
            int    rcount      = colheaders.Rows.Count;
            int    ccount      = colheaders.Columns.Count;

            string[,] CHeaders = new string[rcount, ccount];
            for (int i = 0; i < rcount; i++)
            {
                for (int j = 0; j < ccount; j++)
                {
                    if (colheaders[i, j] != null)
                    {
                        CHeaders[i, j] = colheaders[i, j].ToString();
                    }
                }
            }

            return(CHeaders);
        }
Пример #5
0
        //Draw and Fill Grid based on values sent in properties above
        public void DrawFillFlexgrid()
        {
            //string[,] ColHdrArr = new string[4, 7] { {"Test Value = 1", "Test Value = 1", "Test Value = 1","Test Value = 1","Test Value = 1","Test Value = 1", "Total"},
            //                                {"t", "df", "Sig.(2-tailed)", "Mean Diff", "Confidence : 0.95", "Confidence : 0.95", "Total"},
            //                                {"t", "df", "Sig.(2-tailed)", "Mean Diff", "Lower", "Upper", "Total"},
            //                                {"Total", "Total", "Total", "Total", "Total", "Total", "Total"}
            //};

            //string[,] RowHdrArr = new string[8, 5]{ {"A", "M", "S", "S1","Total"},
            //                                        {"A", "M", "S", "S2","Total"},
            //                                        {"A", "M", "S", "S3","Total"},
            //                                        {"A", "F", "S", "S1","Total"},
            //                                        {"A", "F", "S", "S2","Total"},
            //                                        {"A", "F", "S", "S3","Total"},
            //                                        {"A", "F", "S", "S4","Total"},
            //                                        {"Total", "Total", "Total", "Total","Total"}
            //};

            //////// FILLING STRING ARRAY DATA ///// 7 row from rowhdr count, 6 from colhdr count
            //string[,] dataArr = new string[7, 6] {  {"a", "b", "c", "d", "e", "f"},
            //                                        {"a", "b", "c", "d", "e", "f"},
            //                                        {"a", "b", "c", "d", "e", "f"},
            //                                        {"a", "b", "c", "d", "e", "f"},
            //                                        {"a", "b", "c", "d", "e", "f"},
            //                                        {"a", "b", "c", "d", "e", "f"},
            //                                        {"a", "b", "c", "d", "e", "f"}
            //};

            //values set in properties first then those values are used here to generate FlexGrid
            string[,] ColHdrArr = ColHeaders;
            string[,] RowHdrArr = RowHeaders;
            string[,] dataArr   = GridData;

            //Create Headers
            AUGrid c1FlexGrid1 = this.Grid;

            ///////////// merge and sizing /////
            c1FlexGrid1.AllowMerging = AllowMerging.ColumnHeaders | AllowMerging.RowHeaders;
            c1FlexGrid1.AllowSorting = true;

            var rowheaders = c1FlexGrid1.RowHeaders;
            var colheaders = c1FlexGrid1.ColumnHeaders;


            colheaders.Rows[0].AllowMerging        = true;
            colheaders.Rows[0].HorizontalAlignment = HorizontalAlignment.Center;

            rowheaders.Columns[0].AllowMerging      = true;
            rowheaders.Columns[0].VerticalAlignment = VerticalAlignment.Top;


            /////////////Col Headers//////////
            for (int i = colheaders.Rows.Count; i < ColHdrArr.GetLength(0); i++) //datamatrix.GetLength(0)
            {
                C1.WPF.FlexGrid.Row row = new C1.WPF.FlexGrid.Row();
                colheaders.Rows.Add(row);
                row.AllowMerging        = true;
                row.HorizontalAlignment = HorizontalAlignment.Center;
            }
            for (int i = colheaders.Columns.Count; i < ColHdrArr.GetLength(1); i++) // creating col headers
            {
                C1.WPF.FlexGrid.Column col = new C1.WPF.FlexGrid.Column();
                colheaders.Columns.Add(col);
                col.AllowMerging = true;
            }

            //fill col headers
            bool colheadersexists = ((ColHdrArr != null) && (ColHdrArr.Length >= dataArr.GetLength(1))) ? true : false; //length should be same

            for (int i = 0; i < ColHdrArr.GetLength(0); i++)                                                            //datamatrix.GetLength(0)
            {
                for (int j = 0; j < ColHdrArr.GetLength(1); j++)
                {
                    if (colheadersexists)
                    {
                        colheaders[i, j] = ColHdrArr[i, j];
                    }
                    else
                    {
                        colheaders[i, j] = j + 1;//colheadermatrix[i, j];
                    }
                }
            }

            /////////////Row Headers///////////
            for (int i = rowheaders.Columns.Count; i < RowHdrArr.GetLength(1); i++) //datamatrix.GetLength(1)
            {
                C1.WPF.FlexGrid.Column col = new C1.WPF.FlexGrid.Column();
                col.AllowMerging      = true;
                col.VerticalAlignment = VerticalAlignment.Top;
                rowheaders.Columns.Add(col);
            }

            for (int i = rowheaders.Rows.Count; i < RowHdrArr.GetLength(0); i++)
            {
                C1.WPF.FlexGrid.Row row = new C1.WPF.FlexGrid.Row();
                rowheaders.Rows.Add(row);
                row.AllowMerging = true;
            }

            //fill row headers
            bool rowheadersexists = ((RowHdrArr != null) && (RowHdrArr.Length >= dataArr.GetLength(0))) ? true : false;//length should be same

            for (int i = 0; i < RowHdrArr.GetLength(0); i++)
            {
                for (int j = 0; j < RowHdrArr.GetLength(1); j++)  //datamatrix.GetLength(1)
                {
                    if (rowheadersexists)
                    {
                        rowheaders[i, j] = RowHdrArr[i, j];
                    }
                    else
                    {
                        rowheaders[i, j] = i + 1;//colheadermatrix[i, j];
                    }
                }
            }


            bool isemptyrow;

            for (int rw = 0; rw < dataArr.GetLength(0); rw++)
            {
                isemptyrow = true;//assuming row is empty
                for (int c = 0; c < dataArr.GetLength(1); c++)
                {
                    if (dataArr[rw, c] != null && dataArr[rw, c].Trim().Length > 0)
                    {
                        c1FlexGrid1[rw, c] = dataArr[rw, c];
                        isemptyrow         = false;// if it has atleast one column filled then row is not empty
                    }
                }
                //// hide or remove empty row////
                if (isemptyrow)
                {
                    c1FlexGrid1.Rows[rw].Visible = false;
                }
            }
        }