Ejemplo n.º 1
0
        /// <summary>
        /// copies rows of the flex grid into a datatable 
        /// </summary>
        /// <param name="flex">the flexgrid where to copy the values from</param>
        /// <param name="dt">the data table where the data is stored</param>
        /// <param name="bCompleteGrid">true = copies the data OF THE complete grid; false = only selected rows will be copied</param>
        public int CopyFromFlexGrid(C1.Win.C1FlexGrid.C1FlexGrid flex, DataTable dt, bool bCompleteGrid)
        {
            C1.Win.C1FlexGrid.RowCollection rc = flex.Rows.Selected;

            if (bCompleteGrid)
            {
                // get all rows
                rc = flex.Rows;
            }
            else
            {
                //Get selected rows
                rc = flex.Rows.Selected;
            }

            dt.Clear();
            dt.Columns.Clear();

            for (int m = 0; m < flex.Cols.Count; m++)
            {
                dt.Columns.Add(m.ToString());
            }

            object[] ObArray = new object[flex.Cols.Count];

            foreach (C1.Win.C1FlexGrid.Row row in rc)  // all rows
            {

                for (int j = 1; j < flex.Cols.Count; j++) // all cols
                {

                    if (flex.Cols[j].Visible)
                    {
                        if (row.Index > 0)
                        {
                             ObArray[j] = flex.GetData(row.Index, j);
                        }
                    }
                }
                if (row.Index > 0)
                {
                    dt.Rows.Add(ObArray);
                }
            }
            return dt.Rows.Count;
        }