private void DataGridWorkBookForm_Load(object sender, System.EventArgs e)
        {
            this.dataGrid1.DataSource = GetARandomTable();
            this.dataGrid2.DataSource = GetARandomTable();
            this.dataGrid3.DataSource = GetARandomTable();
            this.dataGrid4.DataSource = GetARandomTable();
            this.dataGrid5.DataSource = GetARandomTable();

            if (engine == null)
            {
                //Call this to reset static members in case other form is loaded first:
                Syncfusion.Calculate.CalcEngine.ResetSheetFamilyID();

                //Create the engine:
                engine = new Syncfusion.Calculate.CalcEngine(this.dataGrid1);

                //Track dependencies required for auto calculations:
                engine.UseDependencies = true;

                //Register multiple ICalcData objects for cross sheet references:
                int sheetfamilyID = Syncfusion.Calculate.CalcEngine.CreateSheetFamilyID();
                engine.RegisterGridAsSheet("DG1", this.dataGrid1, sheetfamilyID);
                engine.RegisterGridAsSheet("DG2", this.dataGrid2, sheetfamilyID);
                engine.RegisterGridAsSheet("DG3", this.dataGrid3, sheetfamilyID);
                engine.RegisterGridAsSheet("DG4", this.dataGrid4, sheetfamilyID);
                engine.RegisterGridAsSheet("DG5", this.dataGrid5, sheetfamilyID);
            }
        }
Exemplo n.º 2
0
        private void SingleDataGridForm_Load(object sender, System.EventArgs e)
        {
            #region create a DataTable
            this.dt = new DataTable("MyTable");

            int nCols = 5;
            int nRows = 7;

            for (int i = 0; i < nCols; i++)
            {
                this.dt.Columns.Add(new DataColumn(string.Format("{0}", (char)((int)'A' + i))));
            }

            Random r = new Random();

            for (int i = 0; i < nRows; ++i)
            {
                DataRow dr = this.dt.NewRow();

                for (int j = 0; j < nCols; j++)
                {
                    if (j == 0)
                    {
                        dr[j] = (i + 1).ToString();
                    }
                    else if (j == 1)
                    {
                        if (i == 0)
                        {
                            dr[j] = 1;
                        }
                        else
                        {
                            dr[j] = string.Format("=B{0} + {0}", i);
                        }
                    }
                    else
                    {
                        dr[j] = r.Next(100).ToString();
                    }
                }
                this.dt.Rows.Add(dr);
            }
            #endregion


            //dataGrid1 is an instance of CalcDataGrid

            //Set the datasource to a DataTable:
            this.dataGrid1.DataSource = this.dt;


            //Call this to reset static members in case other form is loaded first:
            Syncfusion.Calculate.CalcEngine.ResetSheetFamilyID();
            //Create a CalcEngine object, tie it to the DataGrid that implements ICalcData:
            engine = new Syncfusion.Calculate.CalcEngine(this.dataGrid1);

            //Register multiple ICalcData objects for cross sheet references:
            int sheetfamilyID = Syncfusion.Calculate.CalcEngine.CreateSheetFamilyID();
            engine.RegisterGridAsSheet("SingleGrid", this.dataGrid1, sheetfamilyID);

            //Set the CalcEngine to track dependencies required for auto updating:
            engine.UseDependencies = true;

            //engine.IgnoreValueChanged = True;

            //Call RecalculateRange so any formulas in the data can be initially computed:
            engine.RecalculateRange(RangeInfo.Cells(1, 1, dt.Rows.Count, dt.Columns.Count), this.dataGrid1);

            //engine.IgnoreValueChanged = false;

            #region Adding a formula to the formula library - step 2
            //Adding formulas to the CalcEngine Library:
            //Step 2: Call the AddFunction member of the Engine.



            //Add formula name Min to the Library:
            engine.AddFunction("Mymin", new Syncfusion.Calculate.CalcEngine.LibraryFunction(ComputeMymin));


            #endregion
        }
Exemplo n.º 3
0
        private void gridDataBoundGridWorkBookForm_Load(object sender, System.EventArgs e)
        {
            this.gridDataBoundGrid1.DataSource = GetARandomTable();
            this.gridDataBoundGrid2.DataSource = GetARandomTable();
            this.gridDataBoundGrid3.DataSource = GetARandomTable();
            this.gridDataBoundGrid4.DataSource = GetARandomTable();
            this.gridDataBoundGrid5.DataSource = GetARandomTable();


            this.gridDataBoundGrid1.GridVisualStyles                     = Syncfusion.Windows.Forms.GridVisualStyles.Metro;
            this.gridDataBoundGrid1.Properties.BackgroundColor           = System.Drawing.Color.FromArgb(((System.Byte)(227)), ((System.Byte)(239)), ((System.Byte)(255)));
            this.gridDataBoundGrid1.Properties.GridLineColor             = System.Drawing.Color.FromArgb(((System.Byte)(208)), ((System.Byte)(215)), ((System.Byte)(229)));
            this.gridDataBoundGrid1.Model.Options.DefaultGridBorderStyle = GridBorderStyle.Solid;
            this.gridDataBoundGrid1.ForeColor      = System.Drawing.Color.MidnightBlue;
            this.gridDataBoundGrid1.ThemesEnabled  = true;
            this.gridDataBoundGrid1.Model.RowCount = 45;
            this.gridDataBoundGrid1.Font           = new System.Drawing.Font("Segoe UI", 8.5F);

            this.gridDataBoundGrid2.GridVisualStyles                     = Syncfusion.Windows.Forms.GridVisualStyles.Metro;
            this.gridDataBoundGrid2.Properties.BackgroundColor           = System.Drawing.Color.FromArgb(((System.Byte)(227)), ((System.Byte)(239)), ((System.Byte)(255)));
            this.gridDataBoundGrid2.Properties.GridLineColor             = System.Drawing.Color.FromArgb(((System.Byte)(208)), ((System.Byte)(215)), ((System.Byte)(229)));
            this.gridDataBoundGrid2.Model.Options.DefaultGridBorderStyle = GridBorderStyle.Solid;
            this.gridDataBoundGrid2.ForeColor      = System.Drawing.Color.MidnightBlue;
            this.gridDataBoundGrid2.ThemesEnabled  = true;
            this.gridDataBoundGrid2.Model.RowCount = 45;
            this.gridDataBoundGrid2.AllowProportionalColumnSizing = true;
            this.gridDataBoundGrid2.Font = new System.Drawing.Font("Segoe UI", 8.5F);

            this.gridDataBoundGrid3.GridVisualStyles                     = Syncfusion.Windows.Forms.GridVisualStyles.Metro;
            this.gridDataBoundGrid3.Properties.BackgroundColor           = System.Drawing.Color.FromArgb(((System.Byte)(227)), ((System.Byte)(239)), ((System.Byte)(255)));
            this.gridDataBoundGrid3.Properties.GridLineColor             = System.Drawing.Color.FromArgb(((System.Byte)(208)), ((System.Byte)(215)), ((System.Byte)(229)));
            this.gridDataBoundGrid3.Model.Options.DefaultGridBorderStyle = GridBorderStyle.Solid;
            this.gridDataBoundGrid3.ForeColor     = System.Drawing.Color.MidnightBlue;
            this.gridDataBoundGrid3.ThemesEnabled = true;
            this.gridDataBoundGrid3.AllowProportionalColumnSizing = true;
            this.gridDataBoundGrid3.Font = new System.Drawing.Font("Segoe UI", 8.5F);

            this.gridDataBoundGrid4.GridVisualStyles                     = Syncfusion.Windows.Forms.GridVisualStyles.Metro;
            this.gridDataBoundGrid4.Properties.BackgroundColor           = System.Drawing.Color.FromArgb(((System.Byte)(227)), ((System.Byte)(239)), ((System.Byte)(255)));
            this.gridDataBoundGrid4.Properties.GridLineColor             = System.Drawing.Color.FromArgb(((System.Byte)(208)), ((System.Byte)(215)), ((System.Byte)(229)));
            this.gridDataBoundGrid4.Model.Options.DefaultGridBorderStyle = GridBorderStyle.Solid;
            this.gridDataBoundGrid4.ForeColor      = System.Drawing.Color.MidnightBlue;
            this.gridDataBoundGrid4.ThemesEnabled  = true;
            this.gridDataBoundGrid4.Model.RowCount = 25;
            this.gridDataBoundGrid4.AllowProportionalColumnSizing = true;
            this.gridDataBoundGrid4.Font = new System.Drawing.Font("Segoe UI", 8.5F);

            this.gridDataBoundGrid5.GridVisualStyles                     = Syncfusion.Windows.Forms.GridVisualStyles.Metro;
            this.gridDataBoundGrid5.Properties.BackgroundColor           = System.Drawing.Color.FromArgb(((System.Byte)(227)), ((System.Byte)(239)), ((System.Byte)(255)));
            this.gridDataBoundGrid5.Properties.GridLineColor             = System.Drawing.Color.FromArgb(((System.Byte)(208)), ((System.Byte)(215)), ((System.Byte)(229)));
            this.gridDataBoundGrid5.Model.Options.DefaultGridBorderStyle = GridBorderStyle.Solid;
            this.gridDataBoundGrid5.ForeColor      = System.Drawing.Color.MidnightBlue;
            this.gridDataBoundGrid5.ThemesEnabled  = true;
            this.gridDataBoundGrid5.Model.RowCount = 45;
            this.gridDataBoundGrid5.AllowProportionalColumnSizing = true;
            this.gridDataBoundGrid5.Font = new System.Drawing.Font("Segoe UI", 8.5F);

            if (engine == null)
            {
                //Create the engine:
                engine = new Syncfusion.Calculate.CalcEngine(this.gridDataBoundGrid1);
                //Track dependencies required for auto calculations:
                engine.UseDependencies = true;

                //Register multiple ICalcData objects for cross sheet references:
                int sheetfamilyID = Syncfusion.Calculate.CalcEngine.CreateSheetFamilyID();
                engine.RegisterGridAsSheet("GDBG1", this.gridDataBoundGrid1, sheetfamilyID);
                engine.RegisterGridAsSheet("GDBG2", this.gridDataBoundGrid2, sheetfamilyID);
                engine.RegisterGridAsSheet("GDBG3", this.gridDataBoundGrid3, sheetfamilyID);
                engine.RegisterGridAsSheet("GDBG4", this.gridDataBoundGrid4, sheetfamilyID);
                engine.RegisterGridAsSheet("GDBG5", this.gridDataBoundGrid5, sheetfamilyID);
            }
        }