public Form1() { InitializeComponent(); gridControl1.RowCount = 1000; gridControl1.ColCount = 10; for (int i = 1; i < gridControl1.RowCount; i++) { for (int j = 1; j <= gridControl1.ColCount; j++) { if (j != 7) { { gridControl1[i, j].CellValue = 100 * i + j; } } } } RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.DoubleTextBox); for (int i = 1; i <= gridControl1.RowCount; i++) { gridControl1[i, 7].CellType = CustomCellTypes.DoubleTextBox.ToString(); gridControl1[i, 7].CellValue = 0; } //Event Subscription gridControl1.DrawCellDisplayText += GridControl1_DrawCellDisplayText; }
private void InitializeGrid() { #region "Style declaration" //headerStyle this.gridControl1.DefaultRowHeight = (int)DpiAware.LogicalToDeviceUnits(22.0f); GridStyleInfo headerstyle = new GridStyleInfo(); headerstyle.Font.Size = 12; headerstyle.Font.Bold = true; headerstyle.VerticalAlignment = GridVerticalAlignment.Middle; headerstyle.HorizontalAlignment = GridHorizontalAlignment.Center; headerstyle.CellType = GridCellTypeName.Static; //subheaderstyle GridStyleInfo subheaderstyle = new GridStyleInfo(); subheaderstyle.Font.Bold = true; subheaderstyle.VerticalAlignment = GridVerticalAlignment.Middle; subheaderstyle.HorizontalAlignment = GridHorizontalAlignment.Center; subheaderstyle.CellType = GridCellTypeName.Static; GridStyleInfo valuestyle = new GridStyleInfo(); valuestyle.BackColor = SystemColors.Menu; valuestyle.TextColor = Color.Black; valuestyle.VerticalAlignment = GridVerticalAlignment.Middle; valuestyle.HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; #endregion gridControl1.BeginUpdate(); #region "CellButton" int rowIndex = 1, colIndex = 5; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Cell Buttons"; gridControl1.CellModels.Add("DragButton", new DragButtonCellModel(gridControl1.Model)); rowIndex = 4; gridControl1[rowIndex, 2].Text = "Press and Drag Button"; gridControl1[rowIndex, 2].Font.Bold = true; gridControl1[rowIndex, 4].CellType = "DragButton"; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 2, rowIndex, 3)); gridControl1.CellModels.Add("EllipsisText", new EllipsisCellModel(gridControl1.Model)); gridControl1[rowIndex, 8].Text = "Browse Me"; gridControl1[rowIndex, 8].Font.Bold = true; gridControl1[rowIndex, 8].CellType = "EllipsisText"; //gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cells(3, 6, 10, 6)); gridControl1.Model.CellModels.Add("MultipleButton", new MultipleButtonGridCell.MultipleButtonCellModel(gridControl1.Model)); rowIndex = 6; gridControl1[rowIndex, 2].Text = "MultiButtonCell"; gridControl1[rowIndex, 2].Font.Bold = true; //gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cells(6, 2, 8, 2)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(6, 4, 6, 5)); gridControl1.QueryCellInfo += new GridQueryCellInfoEventHandler(gridControl1_QueryCellInfo); #endregion #region "OleContainerCell" colIndex = 2; RegisterCellModel.GridCellType(this.gridControl1, CustomCellTypes.OleContainerCell); rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1.CellModels.Add("LinkLabelCell", new LinkLabelCellModel(gridControl1.Model)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "OLEContainer Cell"; rowIndex += 2; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Click the image to open the file with its default file handler"; rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 2, colIndex)); gridControl1[rowIndex, colIndex].CellType = CustomCellTypes.OleContainerCell.ToString(); gridControl1[rowIndex, colIndex].Description = GetIconFile(@"Data\DocIO\SalesInvoiceDemo.doc"); colIndex = 4; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 2, colIndex)); gridControl1[rowIndex, colIndex].CellType = CustomCellTypes.OleContainerCell.ToString(); gridControl1[rowIndex, colIndex].Description = GetIconFile(@"Data\XlsIO\BudgetPlanner.xls"); colIndex = 6; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 2, colIndex)); gridControl1[rowIndex, colIndex].CellType = CustomCellTypes.OleContainerCell.ToString(); gridControl1[rowIndex, colIndex].Description = GetIconFile(@"Data\PDF\CaseStudy.pdf"); colIndex = 2; rowIndex += 4; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 2, colIndex)); gridControl1[rowIndex, colIndex].CellType = CustomCellTypes.OleContainerCell.ToString(); gridControl1[rowIndex, colIndex].Description = GetIconFile(@"Data\DocIO\Arabic.txt"); colIndex = 4; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 2, colIndex)); gridControl1[rowIndex, colIndex].CellType = CustomCellTypes.OleContainerCell.ToString(); gridControl1[rowIndex, colIndex].Description = GetIconFile(@"Common\Images\Grid\CustomBorder\back3.jpg"); colIndex = 6; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 2, colIndex)); gridControl1[rowIndex, colIndex].CellType = CustomCellTypes.OleContainerCell.ToString(); gridControl1[rowIndex, colIndex].Description = @"http://www.syncfusion.com/"; gridControl1[13, 8] = subheaderstyle; gridControl1[13, 8].Text = "Preview"; gridControl1[13, 8].BackColor = Color.LightGray; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(14, 8, 16, 8)); gridControl1[17, 8].CellType = GridCellTypeName.PushButton; gridControl1[17, 8].Description = "Select a file for preview"; this.gridControl1.Model.ColWidths[8] = (int)DpiAware.LogicalToDeviceUnits(127); rowIndex++; colIndex = 5; #endregion #region "SliderCells" rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Slider Cells"; gridControl1.CellModels.Add("Slider", new SliderCellModel(gridControl1.Model)); rowIndex += 3; SliderStyleProperties tsp = new SliderStyleProperties(new GridStyleInfo(gridControl1.TableStyle)); tsp.Orientation = Orientation.Horizontal; GridStyleInfo style; SliderStyleProperties sp; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex + 1, 4)); style = gridControl1[rowIndex, 3]; sp = new SliderStyleProperties(style); style.CellType = "Slider"; sp.Maximum = 60; sp.Minimum = 0; sp.TickFrequency = 8; sp.LargeChange = 16; sp.SmallChange = 4; sp.Orientation = Orientation.Horizontal; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 5, rowIndex + 1, 5)); style = gridControl1[rowIndex, 5]; sp = new SliderStyleProperties(style); style.CellType = "Slider"; sp.Maximum = 40; sp.Minimum = 0; sp.TickFrequency = 8; sp.LargeChange = 16; sp.SmallChange = 4; sp.Orientation = Orientation.Horizontal; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 6, rowIndex + 7, 6)); style = gridControl1[rowIndex, 6]; sp = new SliderStyleProperties(style); style.CellType = "Slider"; sp.Maximum = 40; sp.Minimum = 0; sp.TickFrequency = 8; sp.LargeChange = 16; sp.SmallChange = 4; sp.Orientation = Orientation.Vertical; gridControl1.EndUpdate(true); #endregion #region "ButtonEdit Cells" rowIndex = 31; #if HELPERCLASS // Added from the source of Syncfusion.GridHelperClasses RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.ButtonEdit); #else this.gridControl1.CellModels.Add("ButtonEdit", new ButtonEditCellModel(this.gridControl1.Model)); #endif gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Button Edit Cells"; rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "ButtonEdit displaying common images and getting from file"; rowIndex++; rowIndex++; gridControl1[rowIndex, 2].FloatCell = true; gridControl1[rowIndex, 2].Text = "Common Images"; gridControl1[rowIndex, 2].TextColor = Color.Black; gridControl1[rowIndex, 4].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(this.gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = Syncfusion.GridHelperClasses.ButtonType.Check; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Check; #endif gridControl1[rowIndex, 5].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Down; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Down; #endif gridControl1[rowIndex, 6].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Undo; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Undo; #endif rowIndex++; rowIndex++; gridControl1[rowIndex, 2].FloatCell = true; gridControl1[rowIndex, 2].Text = "From File"; gridControl1[rowIndex, 2].TextColor = Color.Black; gridControl1[rowIndex, 4].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Image; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Image; #endif #if NETCORE Image bmp = Image.FromFile(@"..//..//..//delete.png"); #else Image bmp = Image.FromFile(@"..//..//delete.png"); #endif bsp.ButtonEditInfo.Image = bmp; gridControl1[rowIndex, 5].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Image; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Image; #endif #if NETCORE bmp = Image.FromFile(@"..//..//..//about.png"); #else bmp = Image.FromFile(@"..//..//about.png"); #endif bsp.ButtonEditInfo.Image = bmp; gridControl1[rowIndex, 6].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Image; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Image; #endif #if NETCORE bmp = Image.FromFile(@"..//..//..//disk_blue.png"); #else bmp = Image.FromFile(@"..//..//disk_blue.png"); #endif bsp.ButtonEditInfo.Image = bmp; rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "ButtonEdit cell with formatting options like textcolor, alignment, borders.."; rowIndex++; rowIndex++; gridControl1[rowIndex, 2].FloatCell = true; gridControl1[rowIndex, 2].Text = "With Colors"; gridControl1[rowIndex, 2].TextColor = Color.Black; gridControl1[rowIndex, 4].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #endif bsp.ButtonEditInfo.ForceBackColor = true; bsp.ButtonEditInfo.BackColor = Color.LightGreen; gridControl1[rowIndex, 5].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #endif bsp.ButtonEditInfo.ForceBackColor = true; bsp.ButtonEditInfo.BackColor = Color.LightPink; gridControl1[rowIndex, 6].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #endif bsp.ButtonEditInfo.ForceBackColor = true; bsp.ButtonEditInfo.BackColor = Color.LightSkyBlue; rowIndex++; rowIndex++; gridControl1[rowIndex, 2].FloatCell = true; gridControl1[rowIndex, 2].Text = "Text Alignment"; gridControl1[rowIndex, 2].TextColor = Color.Black; gridControl1[rowIndex, 4].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 4]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #endif bsp.ButtonEditInfo.Width = (int)DpiAware.LogicalToDeviceUnits(50); bsp.ButtonEditInfo.Text = "Sync"; bsp.ButtonEditInfo.HorizontalAlignment = GridHorizontalAlignment.Right; bsp.ButtonEditInfo.VerticalAlignment = GridVerticalAlignment.Top; gridControl1[rowIndex, 5].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #endif bsp.ButtonEditInfo.Width = (int)DpiAware.LogicalToDeviceUnits(50); bsp.ButtonEditInfo.Text = "Sync"; bsp.ButtonEditInfo.HorizontalAlignment = GridHorizontalAlignment.Left; bsp.ButtonEditInfo.VerticalAlignment = GridVerticalAlignment.Bottom; gridControl1[rowIndex, 6].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.None; #endif bsp.ButtonEditInfo.Width = (int)DpiAware.LogicalToDeviceUnits(50); bsp.ButtonEditInfo.Text = "Sync"; bsp.ButtonEditInfo.HorizontalAlignment = GridHorizontalAlignment.Center; bsp.ButtonEditInfo.VerticalAlignment = GridVerticalAlignment.Middle; rowIndex++; rowIndex++; gridControl1[rowIndex, 2].FloatCell = true; gridControl1[rowIndex, 2].Text = "Button Alignment with Left & Right"; gridControl1[rowIndex, 2].TextColor = Color.Black; gridControl1.Model.RowHeights[rowIndex] = (int)DpiAware.LogicalToDeviceUnits(20); gridControl1[rowIndex, 5].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Leftend; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 5]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Leftend; #endif bsp.ButtonEditInfo.IsLeft = true; gridControl1[rowIndex, 6].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Rightend; #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 6]); bsp.ButtonEditInfo.ButtonEditType = ButtonType.Rightend; #endif bsp.ButtonEditInfo.IsLeft = false; rowIndex++; rowIndex++; gridControl1[rowIndex, 2].FloatCell = true; gridControl1[rowIndex, 2].Text = "Border around button"; gridControl1[rowIndex, 2].TextColor = Color.Black; gridControl1[rowIndex, 5].CellType = "ButtonEdit"; #if HELPERCLASS bsp = new Syncfusion.GridHelperClasses.ButtonEditStyleProperties(gridControl1[rowIndex, 5]); #else bsp = new ButtonEditStyleProperties(gridControl1[rowIndex, 5]); #endif bsp.ButtonEditInfo.Width = (int)DpiAware.LogicalToDeviceUnits(30); #if HELPERCLASS ((Syncfusion.GridHelperClasses.ButtonEditCellModel) this.gridControl1.CellModels["ButtonEdit"]).GridDrawButtonFace += new Syncfusion.GridHelperClasses.ButtonEditCellModel.GridDrawButtonFaceEventHandler(Form1_GridDrawButtonFace); #else ((ButtonEditCellModel)this.gridControl1.CellModels["ButtonEdit"]).GridDrawButtonFace += new ButtonEditCellModel.GridDrawButtonFaceEventHandler(Form1_GridDrawButtonFace); #endif #endregion #region "LinkLabel" rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); //gridControl1.CellModels.Add("LinkLabelCell", new LinkLabelCellModel(gridControl1.Model)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Link Label Cells"; rowIndex += 3; gridControl1[rowIndex, colIndex].CellType = "LinkLabelCell"; gridControl1[rowIndex, colIndex].Text = "Syncfusion, Inc."; gridControl1[rowIndex, colIndex].Font.Bold = true; gridControl1[rowIndex, colIndex].Tag = "http://www.syncfusion.com"; gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].CellType = "LinkLabelCell"; gridControl1[rowIndex, colIndex].Text = "Windows Forms FAQ"; gridControl1[rowIndex, colIndex].Font.Bold = true; gridControl1[rowIndex, colIndex].Tag = "http://www.syncfusion.com/support/forums/grid-windows"; gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].CellType = "LinkLabelCell"; gridControl1[rowIndex, colIndex].Text = "Microsoft Windows Forms"; gridControl1[rowIndex, colIndex].Font.Bold = true; gridControl1[rowIndex, colIndex].Tag = "http://windowsforms.net/"; gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].CellType = "LinkLabelCell"; gridControl1[rowIndex, colIndex].Text = "MSDN"; gridControl1[rowIndex, colIndex].Font.Bold = true; gridControl1[rowIndex, colIndex].Tag = "http://msdn.microsoft.com"; gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; //gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cells(9, 5, 17, 5)); #endregion this.gridControl1.Model.Options.DisplayEmptyColumns = true; this.gridControl1.Model.Options.DisplayEmptyRows = true; gridControl1.EndUpdate(true); gridControl1.Refresh(); }
private void InitializeGrid() { #region "Style declaration" //header Style this.gridControl1.DefaultRowHeight = 22; GridStyleInfo headerstyle = new GridStyleInfo(); headerstyle.Font.Size = 12; headerstyle.Font.Bold = true; headerstyle.VerticalAlignment = GridVerticalAlignment.Middle; headerstyle.HorizontalAlignment = GridHorizontalAlignment.Center; headerstyle.CellType = GridCellTypeName.Static; //Subheader Style GridStyleInfo subheaderstyle = new GridStyleInfo(); subheaderstyle.Font.Bold = true; subheaderstyle.VerticalAlignment = GridVerticalAlignment.Middle; subheaderstyle.HorizontalAlignment = GridHorizontalAlignment.Center; subheaderstyle.CellType = GridCellTypeName.Static; //Value Style GridStyleInfo valuestyle = new GridStyleInfo(); valuestyle.BackColor = SystemColors.Menu; valuestyle.TextColor = Color.Black; valuestyle.VerticalAlignment = GridVerticalAlignment.Middle; valuestyle.HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; #endregion #region "Date Time Picker Cells" int rowIndex = 1, colIndex = 4; gridControl1.AllowProportionalColumnSizing = true; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Date Time Picker Cells"; rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex, 5)); this.gridControl1[rowIndex, colIndex - 1].Text = "Date Picker : (MM/dd/yyyy hh:mm)"; this.gridControl1[rowIndex, colIndex - 1].TextColor = Color.Black; colIndex++; colIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex, colIndex + 1)); this.gridControl1.CellModels.Add("DateTimePicker", new DateTimeCellModel(this.gridControl1.Model)); this.gridControl1[rowIndex, colIndex].CellType = "DateTimePicker"; this.gridControl1[rowIndex, colIndex].CellValueType = typeof(DateTime); this.gridControl1[rowIndex, colIndex].CellValue = DateTime.Now; this.gridControl1[rowIndex, colIndex].Format = "MM/dd/yyyy hh:mm"; rowIndex++; rowIndex++; colIndex -= 2; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex, 5)); this.gridControl1[rowIndex, colIndex - 1].Text = "Time Picker cell : (hh:mm:ss tt)"; this.gridControl1[rowIndex, colIndex - 1].TextColor = Color.Black; colIndex++; colIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex, colIndex + 1)); this.gridControl1[rowIndex, colIndex].CellType = "DateTimePicker"; this.gridControl1[rowIndex, colIndex].CellValueType = typeof(DateTime); this.gridControl1[rowIndex, colIndex].CellValue = DateTime.Now; this.gridControl1[rowIndex, colIndex].Format = "hh:mm:ss tt"; #endregion #region "DropDownGrid cells" GridControl GridA = new GridControl(); GridA.RowCount = 10; GridA.ColCount = 5; GridA.ThemesEnabled = true; GridA.CausesValidation = false; GridA[1, 1].Text = "Grid A"; GridA.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Office2007Blue; GridA.Properties.BackgroundColor = System.Drawing.Color.FromArgb(((System.Byte)(227)), ((System.Byte)(239)), ((System.Byte)(255))); GridA.Properties.GridLineColor = System.Drawing.Color.FromArgb(((System.Byte)(208)), ((System.Byte)(215)), ((System.Byte)(229))); GridA.DefaultGridBorderStyle = GridBorderStyle.Solid; GridA.ForeColor = System.Drawing.Color.MidnightBlue; GridA.Font = new System.Drawing.Font("Verdana", 8.5F); GridControl GridB = new GridControl(); GridB.RowCount = 6; GridB.ColCount = 6; GridB.CausesValidation = false; GridB.ThemesEnabled = true; GridB[1, 1].Text = "Grid B"; GridB.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro; DropDownGridCellModel aModel = new DropDownGridCellModel(this.gridControl1.Model); aModel.EmbeddedGrid = GridA; DropDownGridCellModel bModel = new DropDownGridCellModel(this.gridControl1.Model); bModel.EmbeddedGrid = GridB; gridControl1.CellModels.Add("GridADropCell", aModel); gridControl1.CellModels.Add("GridBDropCell", bModel); rowIndex += 3; colIndex -= 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "DropDown Grid Cells"; rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex, colIndex + 1)); this.gridControl1[rowIndex, colIndex].Text = "Grid A"; this.gridControl1[rowIndex, colIndex].CellType = "GridADropCell"; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex + 3, rowIndex, colIndex + 4)); this.gridControl1[rowIndex, colIndex + 3].Text = "Grid B"; this.gridControl1[rowIndex, colIndex + 3].CellType = "GridBDropCell"; #endregion #region "DropDown Form and User Control" rowIndex += 3; colIndex -= 2; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "DropDown Form and User Control"; rowIndex++; rowIndex++; this.gridControl1.CellModels.Add("DropDownForm", new DropDownFormCellModel(this.gridControl1.Model, new DropDownForm())); this.gridControl1.CellModels.Add("DropDownUserControl", new DropDownUserCellModel(this.gridControl1.Model, new DropDownUser())); ////DropDownForm... rowIndex++; colIndex = 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex, 4)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 5, rowIndex, 7)); gridControl1[rowIndex, colIndex].Text = "DropDownForm"; gridControl1[rowIndex, colIndex].TextColor = Color.Black; this.gridControl1[rowIndex, colIndex + 2].CellType = "DropDownForm"; this.gridControl1[rowIndex, colIndex + 2].Text = "choice1,choice3"; ////DropDownForm... rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 3, rowIndex, 4)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 5, rowIndex, 7)); gridControl1[rowIndex, colIndex].Text = "DropDownUserControl"; gridControl1[rowIndex, colIndex].TextColor = Color.Black; this.gridControl1[rowIndex, colIndex + 2].CellType = "DropDownUserControl"; this.gridControl1[rowIndex, colIndex + 2].Text = "choice1,choice3"; #endregion #region "DropDOwnCalculator Cell" rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "DropDown Calculator TextBox"; rowIndex++; rowIndex++; #if HELPERCLASS RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.CalculatorTextBox); #else this.gridControl1.CellModels.Add("CalculatorTextBox", new DropDownCalculatorTextBoxCellModel(this.gridControl1.Model)); #endif rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 4, rowIndex, 6)); CalculatorControl c1 = new CalculatorControl(); c1.BorderStyle = Border3DStyle.Flat; c1.ButtonStyle = Syncfusion.Windows.Forms.ButtonAppearance.Office2007; c1.UseVisualStyle = true; GridStyleInfo style = gridControl1[rowIndex, 4]; style.CellType = "CalculatorTextBox"; style.Control = c1; style.Text = "Calculator TextBox"; this.gridControl1.Model.EnableGridListControlInComboBox = false; #endregion }
private void InitializeGrid() { #region "Style declaration" GridStyleInfo headerstyle = new GridStyleInfo(); headerstyle.Font.Size = 12; headerstyle.Font.Bold = true; headerstyle.VerticalAlignment = GridVerticalAlignment.Middle; headerstyle.HorizontalAlignment = GridHorizontalAlignment.Center; headerstyle.CellType = GridCellTypeName.Static; GridStyleInfo subheaderstyle = new GridStyleInfo(); subheaderstyle.Font.Bold = true; subheaderstyle.VerticalAlignment = GridVerticalAlignment.Middle; subheaderstyle.HorizontalAlignment = GridHorizontalAlignment.Center; subheaderstyle.CellType = GridCellTypeName.Static; GridStyleInfo valuestyle = new GridStyleInfo(); valuestyle.BackColor = SystemColors.Menu; valuestyle.TextColor = Color.Black; valuestyle.VerticalAlignment = GridVerticalAlignment.Middle; valuestyle.HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.TableStyle.FloatCell = true; gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; gridControl1.DefaultRowHeight = 22; #endregion gridControl1.BeginUpdate(); int rowIndex = 1, colIndex = 4; #region "IntegerTextBox" gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Integer TextBox Cell"; rowIndex += 3; RegisterCellModel.GridCellType(this.gridControl1, CustomCellTypes.IntegerTextBox); this.gridControl1[rowIndex, colIndex - 2].Text = ".CellType = CustomCellTypes.IntegerTextBox"; this.gridControl1[rowIndex, colIndex - 2].HorizontalAlignment = GridHorizontalAlignment.Center; this.gridControl1[rowIndex, colIndex + 2] = valuestyle; this.gridControl1[rowIndex, colIndex + 2].CellType = CustomCellTypes.IntegerTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 2].CellValue = 56789; this.gridControl1[rowIndex, colIndex + 3] = valuestyle; this.gridControl1[rowIndex, colIndex + 3].CellType = CustomCellTypes.IntegerTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 3].CellValue = 34210; rowIndex++; this.gridControl1[rowIndex, colIndex + 2] = valuestyle; this.gridControl1[rowIndex, colIndex + 2].CellType = CustomCellTypes.IntegerTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 2].CellValue = 1234; this.gridControl1[rowIndex, colIndex + 3] = valuestyle; this.gridControl1[rowIndex, colIndex + 3].CellType = CustomCellTypes.IntegerTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 3].CellValue = 54321; #endregion #region "DoubleTextBox" rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Double TextBox Cell"; rowIndex += 3; RegisterCellModel.GridCellType(this.gridControl1, CustomCellTypes.DoubleTextBox); this.gridControl1[rowIndex, colIndex - 2].Text = ".CellType = CustomCellTypes.DoubleTextBox"; this.gridControl1[rowIndex, colIndex - 2].HorizontalAlignment = GridHorizontalAlignment.Center; this.gridControl1[rowIndex, colIndex + 2] = valuestyle; this.gridControl1[rowIndex, colIndex + 2].CellType = CustomCellTypes.DoubleTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 2].CellValue = 123456; this.gridControl1[rowIndex, colIndex + 3] = valuestyle; this.gridControl1[rowIndex, colIndex + 3].CellType = CustomCellTypes.DoubleTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 3].CellValue = 876543; rowIndex++; this.gridControl1[rowIndex, colIndex + 2] = valuestyle; this.gridControl1[rowIndex, colIndex + 2].CellType = CustomCellTypes.DoubleTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 2].CellValue = 13579; this.gridControl1[rowIndex, colIndex + 3] = valuestyle; this.gridControl1[rowIndex, colIndex + 3].CellType = CustomCellTypes.DoubleTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 3].CellValue = 975324; #endregion #region "Percentage TextBox" rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Percentage TextBox Cell"; rowIndex += 3; RegisterCellModel.GridCellType(this.gridControl1, CustomCellTypes.PercentTextBox); this.gridControl1[rowIndex, colIndex - 2].Text = ".CellType = CustomCellTypes.DoubleTextBox"; this.gridControl1[rowIndex, colIndex - 2].HorizontalAlignment = GridHorizontalAlignment.Center; this.gridControl1[rowIndex, colIndex + 2] = valuestyle; this.gridControl1[rowIndex, colIndex + 2].CellType = CustomCellTypes.PercentTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 2].CellValue = 54; this.gridControl1[rowIndex, colIndex + 3] = valuestyle; this.gridControl1[rowIndex, colIndex + 3].CellType = CustomCellTypes.PercentTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 3].CellValue = 65; rowIndex++; this.gridControl1[rowIndex, colIndex + 2] = valuestyle; this.gridControl1[rowIndex, colIndex + 2].CellType = CustomCellTypes.PercentTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 2].CellValue = 84; this.gridControl1[rowIndex, colIndex + 3] = valuestyle; this.gridControl1[rowIndex, colIndex + 3].CellType = CustomCellTypes.PercentTextBox.ToString(); this.gridControl1[rowIndex, colIndex + 3].CellValue = 92; #endregion #region "EnhancedNumericUpdown" rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Enhanced Numeric Up-Down Cell"; RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.FNumericUpDown); rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Allow Decimal Increment and Decrement(step by 0.2,0.01,0.001)"; #region #1 rowIndex++; rowIndex++; gridControl1.Model.RowHeights[rowIndex] = 20; GridStyleInfo style = gridControl1[rowIndex, colIndex - 1]; style.CellType = "FNumericUpDown"; style.Text = "0.5"; FloatNumericUpDownStyleProperties sp = new FloatNumericUpDownStyleProperties(style); sp.StyleInfo.BackColor = SystemColors.Window; sp.FloatNumericUpDownProperties.Maximum = 15.0; sp.FloatNumericUpDownProperties.Minimum = 0.0; sp.FloatNumericUpDownProperties.StartValue = 0.5; sp.FloatNumericUpDownProperties.Step = 0.2; sp.FloatNumericUpDownProperties.WrapValue = true; sp.FloatNumericUpDownProperties.DecimalPlaces = 1; style = gridControl1[rowIndex, colIndex + 1]; style.CellType = "FNumericUpDown"; style.Text = "10.10"; sp = new FloatNumericUpDownStyleProperties(style); sp.StyleInfo.BackColor = SystemColors.Window; sp.FloatNumericUpDownProperties.Maximum = 12.50; sp.FloatNumericUpDownProperties.Minimum = 0.0; sp.FloatNumericUpDownProperties.StartValue = 10.10; sp.FloatNumericUpDownProperties.Step = 0.01; sp.FloatNumericUpDownProperties.WrapValue = true; sp.FloatNumericUpDownProperties.DecimalPlaces = 2; style = gridControl1[rowIndex, colIndex + 3]; style.CellType = "FNumericUpDown"; style.Text = "15.000"; sp = new FloatNumericUpDownStyleProperties(style); sp.StyleInfo.BackColor = SystemColors.Window; sp.FloatNumericUpDownProperties.Maximum = 15.225; sp.FloatNumericUpDownProperties.Minimum = 0.0; sp.FloatNumericUpDownProperties.StartValue = 15.000; sp.FloatNumericUpDownProperties.Step = 0.001; sp.FloatNumericUpDownProperties.WrapValue = true; sp.FloatNumericUpDownProperties.DecimalPlaces = 3; sp.FloatNumericUpDownProperties.Orientation = FloatNumericUpDownProperties.OrientationType.Vertical; sp.FloatNumericUpDownProperties.InterceptArrowkeys = false; sp.FloatNumericUpDownProperties.ThousandsSeparator = false; #endregion #region #2 rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Option to decrease number beyond Zero(Negative numbers allowed)"; rowIndex++; rowIndex++; gridControl1.Model.RowHeights[rowIndex] = 20; style = this.gridControl1[rowIndex, colIndex - 1]; style.CellType = "FNumericUpDown"; style.Text = "-4"; sp = new FloatNumericUpDownStyleProperties(style); #endregion #region #3 rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Use Up/Down arrow keys from Keyboard to increment/decrement the numeric value"; rowIndex++; rowIndex++; gridControl1.Model.RowHeights[rowIndex] = 20; style = this.gridControl1[rowIndex, colIndex - 1]; style.CellType = "FNumericUpDown"; style.Text = "100000"; sp = new FloatNumericUpDownStyleProperties(style); sp.StyleInfo.BackColor = SystemColors.Window; sp.FloatNumericUpDownProperties.Maximum = 10000000000; sp.FloatNumericUpDownProperties.Minimum = 1; sp.FloatNumericUpDownProperties.StartValue = 100000; sp.FloatNumericUpDownProperties.Step = 100; sp.FloatNumericUpDownProperties.WrapValue = true; sp.FloatNumericUpDownProperties.DecimalPlaces = 0; sp.FloatNumericUpDownProperties.Orientation = FloatNumericUpDownProperties.OrientationType.Vertical; sp.FloatNumericUpDownProperties.InterceptArrowkeys = true; sp.FloatNumericUpDownProperties.ThousandsSeparator = false; #endregion #region #4 rowIndex++; rowIndex++; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, gridControl1.ColCount)); gridControl1[rowIndex, 1] = subheaderstyle; gridControl1[rowIndex, 1].Text = "Setting the Orientation property"; rowIndex++; rowIndex++; gridControl1.Model.RowHeights[rowIndex] = 20; style = this.gridControl1[rowIndex, colIndex - 1]; style.CellType = "FNumericUpDown"; style.Text = "5.5"; sp = new FloatNumericUpDownStyleProperties(style); sp.StyleInfo.BackColor = SystemColors.Window; sp.FloatNumericUpDownProperties.Maximum = 15.5; sp.FloatNumericUpDownProperties.Minimum = 0.5; sp.FloatNumericUpDownProperties.StartValue = .5; sp.FloatNumericUpDownProperties.Step = .5; sp.FloatNumericUpDownProperties.WrapValue = true; sp.FloatNumericUpDownProperties.DecimalPlaces = 1; sp.FloatNumericUpDownProperties.Orientation = FloatNumericUpDownProperties.OrientationType.Horizontal; sp.FloatNumericUpDownProperties.InterceptArrowkeys = true; sp.FloatNumericUpDownProperties.ThousandsSeparator = false; style = this.gridControl1[rowIndex, colIndex + 1]; style.CellType = "FNumericUpDown"; style.Text = "10.0"; sp = new FloatNumericUpDownStyleProperties(style); sp.StyleInfo.BackColor = SystemColors.Window; sp.FloatNumericUpDownProperties.Maximum = 15.5; sp.FloatNumericUpDownProperties.Minimum = 0.5; sp.FloatNumericUpDownProperties.Step = .5; sp.FloatNumericUpDownProperties.DecimalPlaces = 1; sp.FloatNumericUpDownProperties.Orientation = FloatNumericUpDownProperties.OrientationType.Vertical; #endregion #endregion this.gridControl1.Model.Options.DisplayEmptyColumns = true; gridControl1.EndUpdate(true); gridControl1.Refresh(); }
private void InitializeGrid() { #region "Style declaration" //headerstyle this.gridControl1.DefaultRowHeight = (int)DpiAware.LogicalToDeviceUnits(22.0f); GridStyleInfo headerstyle = new GridStyleInfo(); headerstyle.Font.Size = 12; headerstyle.Font.Bold = true; headerstyle.TextColor = Color.Black; headerstyle.VerticalAlignment = GridVerticalAlignment.Middle; headerstyle.HorizontalAlignment = GridHorizontalAlignment.Center; headerstyle.CellType = GridCellTypeName.Static; //subheaderstyle GridStyleInfo subheaderstyle = new GridStyleInfo(); subheaderstyle.Font.Bold = true; subheaderstyle.VerticalAlignment = GridVerticalAlignment.Middle; subheaderstyle.HorizontalAlignment = GridHorizontalAlignment.Center; subheaderstyle.CellType = GridCellTypeName.Static; GridStyleInfo valuestyle = new GridStyleInfo(); valuestyle.BackColor = SystemColors.Menu; valuestyle.TextColor = Color.Black; valuestyle.VerticalAlignment = GridVerticalAlignment.Middle; valuestyle.HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; int rowIndex = 1, colIndex = 2; #endregion #region "Chart in Cell" this.InitializeData(); this.gridControl1.CellModels.Add("ChartCell", new GridChartCellModel(this.gridControl1.Model)); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "ChartControl in GridCells"; #region "ChartData" this.gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(4, 4, 4, 8)); style = this.gridControl1[4, 4]; style.Text = "Chart Data"; style.Font.Bold = true; style.Font.Facename = "Times New Roman"; style.Font.Size = 12.75F; style.HorizontalAlignment = GridHorizontalAlignment.Center; this.gridControl1.RowHeights[4] = (int)DpiAware.LogicalToDeviceUnits(21.0f); GridRangeStyle rstyle = new GridRangeStyle(); rstyle.Range = GridRangeInfo.Cell(5, 4); rstyle.StyleInfo.BaseStyle = "Header"; rstyle.StyleInfo.CellType = "Header"; rstyle.StyleInfo.Font.Bold = true; rstyle.StyleInfo.Font.Facename = "Verdana"; rstyle.StyleInfo.Themed = true; this.gridControl1.RangeStyles.Add(rstyle); GridRangeStyle rstyle2 = new GridRangeStyle(); rstyle2.Range = GridRangeInfo.Cells(5, 5, 5, 8); rstyle2.StyleInfo.BaseStyle = "Column Header"; rstyle2.StyleInfo.CellType = "Header"; rstyle2.StyleInfo.Font.Bold = true; rstyle2.StyleInfo.Font.Facename = "Verdana"; rstyle2.StyleInfo.Themed = true; this.gridControl1.RangeStyles.Add(rstyle2); this.gridControl1[5, 5].Text = "Team1"; this.gridControl1[5, 6].Text = "Team2"; this.gridControl1[5, 7].Text = "Team3"; this.gridControl1[5, 8].Text = "Team4"; GridRangeStyle rstyle3 = new GridRangeStyle(); rstyle3.Range = GridRangeInfo.Cells(6, 4, 8, 4); rstyle3.StyleInfo.BaseStyle = "Row Header"; rstyle3.StyleInfo.CellType = "Header"; rstyle3.StyleInfo.Font.Bold = true; rstyle3.StyleInfo.Font.Facename = "Verdana"; rstyle3.StyleInfo.Themed = true; this.gridControl1.RangeStyles.Add(rstyle3); this.gridControl1[6, 4].Text = "Data1"; this.gridControl1[7, 4].Text = "Data2"; this.gridControl1[8, 4].Text = "Data3"; #endregion #region "ChartControl" //Define the Range where the chart should be displayed (8,2,26,8) 27, 2, 28, 8)); this.gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(10, 4, 28, 10)); this.gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(29, 4, 30, 10)); style = this.gridControl1[29, 4]; style.Text = "Interactive Chart Cell - Try Changing the ChartData"; style.Font.Size = 12; style.Font.Bold = true; style.Font.Facename = "Arial"; style.HorizontalAlignment = GridHorizontalAlignment.Center; style = this.gridControl1[10, 4]; style.CellType = "ChartCell"; csp = new ChartStyleProperties(style); csp.ChartType = ChartSeriesType.Column; csp.TitleText = "Chart Cell"; csp.Series3D = false; csp.TitleAlignment = StringAlignment.Center; cm = (GridChartCellModel)this.gridControl1.CellModels["ChartCell"]; ////Pass the CellValueRange and ChartAreaRange to cell model. cm.CellValueRangeInfo = GridRangeInfo.Cells(6, 5, 8, 8); cm.ChartAreaRangeInfo = GridRangeInfo.Cells(8, 2, 26, 9); #endregion #endregion #region "Grid in Cell" rowIndex = 32; colIndex = 4; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "GridInCells"; rowIndex += 3; #if HELPERCLASS RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.GridinCell); #else gridControl1.CellModels.Add("GridinCell", new GridInCellModel(gridControl1.Model)); #endif GridControl grid; this.gridControl1[rowIndex, colIndex].CellType = "GridinCell"; this.gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 4, 10)); grid = new ContentCellDemo.CellEmbeddedGrid(this.gridControl1); grid.DpiAware = true; grid.RowCount = 20; grid.ColCount = 20; grid[1, 1].Text = "this is a 20x20 grid"; grid.ThemesEnabled = true; grid.Office2007ScrollBars = true; this.gridControl1[rowIndex, colIndex].Control = grid; this.gridControl1.Controls.Add(grid); this.gridControl1.DefaultRowHeight = (int)DpiAware.LogicalToDeviceUnits(18.0f); this.gridControl1.DefaultColWidth = (int)DpiAware.LogicalToDeviceUnits(75.0f); grid.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Office2007Blue; this.gridControl1.Model.Options.DisplayEmptyColumns = true; #endregion #region "XHTML Cell" rowIndex = 42; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "XHTML Cells"; rowIndex += 3; RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.XhtmlCell); string xhtml1 = "<body style=\"font-family:Arial; line-height:1em\"> "; xhtml1 += "<h1 style=\"text-align:center; color:#EE7A03 \">XhtmlCells</h1>"; //#008888 xhtml1 += "<p/>"; xhtml1 += "<p>XhtmlCells use the RichTextBoxSupportsXHTML control from GotDotNet user samples to display XHTML formatted text inside a cell.</p>"; xhtml1 += "</body>"; gridControl1[rowIndex, colIndex].CellType = "XhtmlCell"; gridControl1[rowIndex, colIndex].Text = xhtml1; gridControl1.RowHeights[rowIndex] = (int)DpiAware.LogicalToDeviceUnits(50.0f); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, colIndex, rowIndex + 10, colIndex + 6)); rowIndex += 10; rowIndex++; rowIndex++; #endregion #region "Calendar Cells" RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.Calendar); rowIndex = 57; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "Calendar Cells"; rowIndex += 3; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 4, rowIndex + 8, 6)); style = gridControl1[rowIndex, 4]; style.CellType = "Calendar"; style.Control = new MonthCalendar(); gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 8, rowIndex + 8, 10)); style = gridControl1[rowIndex, 8]; style.CellType = "Calendar"; style.Control = new MonthCalendar(); #endregion #region "PictureBoxCells" rowIndex = 71; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex + 1, gridControl1.ColCount)); gridControl1[rowIndex, 1] = headerstyle; gridControl1[rowIndex, 1].Text = "PictureBox Cells"; rowIndex += 3; RegisterCellModel.GridCellType(gridControl1, CustomCellTypes.PictureBox); Syncfusion.GridHelperClasses.PictureBoxStyleProperties tsp = new Syncfusion.GridHelperClasses.PictureBoxStyleProperties(new GridStyleInfo(gridControl1.TableStyle)); tsp.SizeMode = PictureBoxSizeMode.StretchImage; Syncfusion.GridHelperClasses.PictureBoxStyleProperties sp; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 4, rowIndex + 6, 6)); style = gridControl1[rowIndex, 4]; style.CellType = "PictureBox"; sp = new Syncfusion.GridHelperClasses.PictureBoxStyleProperties(style); sp.Image = GetImage("car1.jpg"); sp.SizeMode = PictureBoxSizeMode.StretchImage; gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 8, rowIndex + 6, 10)); style = gridControl1[rowIndex, 8]; style.CellType = "PictureBox"; sp = new Syncfusion.GridHelperClasses.PictureBoxStyleProperties(style); sp.Image = GetImage("car2.jpg"); sp.SizeMode = PictureBoxSizeMode.StretchImage; #endregion this.gridControl1.CurrentCellEditingComplete += new EventHandler(gridControl1_CurrentCellEditingComplete); }
/// <summary> /// Used to load the all worksheets and assign those sheets in grid models. /// </summary> /// <param name="Workbook">Exel work book that needs to be imported.</param> public void LoadWorkbook(TabBarSplitterControl formTabBarSplitterControl, IWorkbook Workbook) { tabBarSplitterControl = formTabBarSplitterControl; formTabBarSplitterControl.TabBarPages.Clear(); workbook = Workbook; GridExcelConverterControl extensions = new GridExcelConverterControl(); gridModelCollection = extensions.ExcelToVirtualGrid(Workbook); for (int i = 0; i < Workbook.Worksheets.Count; i++) { GridControl grid = new GridControl(); //Used to calculate the formula values. Workbook.Worksheets[i].EnableSheetCalculations(); #region Adding Tab pages TabBarPage tab = new TabBarPage(); tab.Text = Workbook.Worksheets[i].Name; tab.Controls.Add(grid); if (Workbook.Worksheets[i].Visibility != WorksheetVisibility.Visible) { tab.Visible = false; } #endregion #region GridModel settings grid.Model = gridModelCollection[i]; #endregion #region Grid customization grid.ThemesEnabled = true; GridMetroColors colors = new GridMetroColors(); colors.HeaderBottomBorderColor = Color.FromArgb(208, 208, 208); colors.HeaderBottomBorderWeight = GridBottomBorderWeight.Thin; grid.SetMetroStyle(colors); grid.FloatCellsMode = GridFloatCellsMode.OnDemandCalculation; grid.ExcelLikeAlignment = true; grid.Model.Options.ExcelLikeCurrentCell = true; grid.Model.Options.ExcelLikeSelectionFrame = true; grid.Model.Options.EnterKeyBehavior = GridDirectionType.Down; grid.ActivateCurrentCellBehavior = GridCellActivateAction.DblClickOnCell; grid.Model.Options.WrapCell = false; grid.Model.CommandStack.Enabled = true; grid.Properties.ForceImmediateRepaint = true; grid.Model.ColWidths[0] = 35; grid.SmoothMouseWheelScrolling = true; RegisterCellModel.GridCellType(grid, CustomCellTypes.LinkLabelCell); #endregion formTabBarSplitterControl.TabBarPages.Add(tab); } formTabBarSplitterControl.ActivePageIndex = 0; foreach (GridModel gridModel in gridModelCollection) { gridModel.QueryCellInfo += new GridQueryCellInfoEventHandler(Model_QueryCellInfo); gridModel.SaveCellInfo += new GridSaveCellInfoEventHandler(gridModel_SaveCellInfo); } }