void SampleGrid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) { GridBorder gb = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(158, 182, 206)); if (e.Style.CellType == GridCellTypeName.Header) { e.Style.Borders.Bottom = e.Style.Borders.Right = gb; } }
public SampleGrid(GridModel model) : base(model) { this.FillSplitterPane = true; // transparent bool alphablending = false; if (alphablending) { this.SupportsTransparentBackColor = true; this.BackColor = Color.FromArgb(99, Color.White); } else { this.BackColor = Color.White; this.ForeColor = SystemColors.WindowText; } this.VerticalThumbTrack = false; this.VerticalScrollTips = true; this.HorizontalThumbTrack = true; this.HorizontalScrollTips = true; //Set properties to get the XP flat look this.ThemesEnabled = true; this.Properties.Buttons3D = false; this.DefaultGridBorderStyle = GridBorderStyle.Solid; this.Properties.GridLineColor = Color.FromArgb(208, 215, 229); this.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro; this.Model.Options.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro; GridStyleInfo style = new GridStyleInfo(); GridBorder gb = new GridBorder(GridBorderStyle.Solid, SystemColors.ControlDark); style.Borders.Bottom = style.Borders.Right = gb; this.BaseStylesMap["Header"].StyleInfo.BackColor = Color.White; this.BaseStylesMap["Header"].StyleInfo.Font.Facename = "Segoe UI"; this.Model.Options.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro; this.Properties.MarkColHeader = true; this.Properties.MarkRowHeader = true; this.TableStyle.Font.Facename = "Segoe UI"; this.TableStyle.Font.Size = 10; //Event Triggering this.Model.ClipboardPaste += model_ClipboardPaste; this.QueryCellInfo += new GridQueryCellInfoEventHandler(SampleGrid_QueryCellInfo); }
private void ПостроитьТаблицуПоМодели(МодельТаблицыОтчетнойФормы МодельТаблицы) { int num2; base.Rows.FrozenCount = МодельТаблицы.КоличествоФиксированныхСтрок; base.Cols.FrozenCount = МодельТаблицы.КоличествоФиксированныхСтолбцов; base.ColCount = МодельТаблицы.КоличествоСтолбцов; base.RowCount = МодельТаблицы.КоличествоСтрок; int index = 1; while (index <= base.ColCount) { if (МодельТаблицы.ШириныСтолбцов[index] == 0) { base.Cols.Hidden[index] = true; } else { base.ColWidths[index] = МодельТаблицы.ШириныСтолбцов[index]; } index++; } for (num2 = 1; num2 <= base.RowCount; num2++) { if (МодельТаблицы.ВысотыСтрок[num2] == 0) { base.Rows.Hidden[num2] = true; } else { base.RowHeights[num2] = МодельТаблицы.ВысотыСтрок[num2]; } } foreach (ОбъединениеЯчеек ячеек in МодельТаблицы.ОбъедиенияЯчеек) { base.CoveredRanges.Add(GridRangeInfo.Cells(ячеек.Top, ячеек.Left, ячеек.Bottom, ячеек.Right)); } this.Представление.BeginUpdate(); Color color = Color.FromArgb(0x24, 0x33, 100); GridBorder border = new GridBorder(GridBorderStyle.Solid, color); for (num2 = 1; num2 <= base.RowCount; num2++) { for (index = 1; index <= base.ColCount; index++) { ЯчейкаТаблицыОтчетнойФормы формы = МодельТаблицы.Ячейки[num2, index]; if (формы != null) { формы.Значение = this.ПроанализироватьСсылкиНаКонстанты(формы.Значение); GridStyleInfo info = base[num2, index]; info.BeginUpdate(); if (формы.Формула) { info.CellType = "FormulaCell"; } if (!string.IsNullOrEmpty(формы.Значение)) { string input = формы.Значение; if (формы.Формула && input.ToUpper().StartsWith("=IF")) { Match match = регулярник.Match(input); if (match.Success) { input = string.Format("={0}", match.Groups["false"]); } } info.CellValue = input; } if (!string.IsNullOrEmpty(формы.ПараметрыШрифта.Наименование)) { info.Font.Facename = формы.ПараметрыШрифта.Наименование; } if (формы.ПараметрыШрифта.азмер != 0f) { info.Font.Size = формы.ПараметрыШрифта.азмер; } if (формы.ПараметрыШрифта.Ориентация != 0) { info.Font.Orientation = формы.ПараметрыШрифта.Ориентация; } info.Font.Bold = формы.ПараметрыШрифта.Жирный; info.Font.Italic = формы.ПараметрыШрифта.Курсив; info.Font.Strikeout = формы.ПараметрыШрифта.Зачеркнутый; info.Font.Underline = формы.ПараметрыШрифта.Подчеркнутый; if (формы.ПараметрыЗаливки != null) { info.Interior = формы.ПараметрыЗаливки; } if (формы.ЦветТекста != Color.Empty) { info.TextColor = формы.ЦветТекста; } if (формы.ВерхняяГраница == ГраницаЯчейки.Выделенная) { info.Borders.Top = border; } if (формы.ЛеваяГраница == ГраницаЯчейки.Выделенная) { info.Borders.Left = border; } if (формы.НижняяГраница == ГраницаЯчейки.Выделенная) { info.Borders.Bottom = border; } if (формы.ПраваяГраница == ГраницаЯчейки.Выделенная) { info.Borders.Right = border; } info.HorizontalAlignment = (GridHorizontalAlignment)формы.ВыравниваниеПоГоризонтали; info.VerticalAlignment = (GridVerticalAlignment)формы.ВыравниваниеПоВертикали; info.EndUpdate(); this.ПроанализироватьЯчейку(формы, num2, index); } } } this.Представление.EndUpdate(); }
/// <summary> /// Setting Grid control Properties /// </summary> private void GridSettings() { this.gridControl1.ControllerOptions = GridControllerOptions.All & (~GridControllerOptions.OleDataSource); gridControl1.CommandStack.Enabled = false; this.excelMarker = new ExcelMarkerMouseController(gridControl1); gridControl1.MouseControllerDispatcher.Add(excelMarker); this.SuspendLayout(); GridBorder thickBorder = new GridBorder(GridBorderStyle.Solid, Color.Gray, GridBorderWeight.Medium); int rowIndex = rowBase + 1; int colIndex = colBase + 1; gridControl1.TableStyle.CheckBoxOptions = new GridCheckBoxCellInfo("True", "False", "", false); gridControl1[rowIndex, colIndex].CellType = "CheckBox"; gridControl1[rowIndex, colIndex].TriState = false; gridControl1[rowIndex, colIndex].Text = "True"; gridControl1[rowIndex, colIndex].VerticalAlignment = GridVerticalAlignment.Middle; gridControl1[rowIndex, colIndex].Description = " ExcelLikeCurrentCell"; rowIndex++; gridControl1[rowIndex, colIndex].CellType = "CheckBox"; gridControl1[rowIndex, colIndex].TriState = false; gridControl1[rowIndex, colIndex].Text = "True"; gridControl1[rowIndex, colIndex].VerticalAlignment = GridVerticalAlignment.Middle; gridControl1[rowIndex, colIndex].Description = " ExcelLikeSelectionFrame"; rowIndex++; gridControl1[rowIndex, colIndex].CellType = "CheckBox"; gridControl1[rowIndex, colIndex].TriState = false; gridControl1[rowIndex, colIndex].Text = "True"; gridControl1[rowIndex, colIndex].VerticalAlignment = GridVerticalAlignment.Middle; gridControl1[rowIndex, colIndex].Description = " ExcelMarker"; rowIndex++; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Top = thickBorder; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; gridControl1[rowIndex, colIndex].Text = "Selection Color"; gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1[rowIndex, colIndex].VerticalAlignment = GridVerticalAlignment.Bottom; gridControl1[rowIndex, colIndex].Font.Size = 8; gridControl1[rowIndex, colIndex].TextColor = Color.Gray; gridControl1[rowIndex, colIndex].Enabled = false; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; gridControl1[rowIndex, colIndex].CellValue = Color.FromName("Highlight");//Color.FromArgb( 255, 187, 111 ); gridControl1[rowIndex, colIndex].CellType = "ColorEdit"; gridControl1[rowIndex, colIndex].TextColor = Color.White; gridControl1[rowIndex, colIndex].CellValueType = typeof(Color); gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1[rowIndex, colIndex].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(163)))), ((int)(((byte)(0))))); gridControl1[rowIndex, colIndex].Font.Size = 8; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; gridControl1[rowIndex, colIndex].Text = "Alpha Blend Value (0-255)"; gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1[rowIndex, colIndex].VerticalAlignment = GridVerticalAlignment.Bottom; gridControl1[rowIndex, colIndex].Font.Size = 8; gridControl1[rowIndex, colIndex].TextColor = Color.Gray; gridControl1[rowIndex, colIndex].Enabled = false; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; gridControl1[rowIndex, colIndex].CellType = "NumericUpDown"; gridControl1[rowIndex, colIndex].CellValue = alphaBlendValue; gridControl1[rowIndex, colIndex].CellValueType = typeof(int); gridControl1[rowIndex, colIndex].NumericUpDown = new GridNumericUpDownCellInfo(0, 255, 0, 1, true); gridControl1[rowIndex, colIndex].HorizontalAlignment = GridHorizontalAlignment.Center; gridControl1[rowIndex, colIndex].Font.Size = 8; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; rowIndex++; gridControl1[rowIndex, colIndex].Borders.Bottom = thickBorder; gridControl1[rowIndex, colIndex].Borders.Left = thickBorder; gridControl1[rowIndex, colIndex].Borders.Right = thickBorder; gridControl1[rowIndex, colIndex].CellType = "PushButton"; gridControl1[rowIndex, colIndex].Description = "Apply"; gridControl1[rowIndex, colIndex].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(163)))), ((int)(((byte)(0))))); gridControl1.Model.RowHeights[rowIndex] = 25; gridControl1.Rows.DefaultSize += 1; gridControl1.DefaultColWidth = 70; gridControl1.ColWidths.SetSize(colIndex, 230); //add a custom cell control that draws a mitmap gridControl1.CellModels.Add("ImageCell", new ImageCellModel(gridControl1.Model)); //read a bitmap from resources //strm = this.GetType().Assembly.GetManifestResourceStream("ExcelMarker.grid.gif"); Bitmap bm = GetImage(@"Common\Images\Grid\SelectionMarker\grid.gif");// new Bitmap(strm); //set up covered cell to show the bitmap gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(1, 2, 5, 9)); gridControl1[1, 2].Tag = bm; //Tag used to hold the bitmap gridControl1[1, 2].CellType = "ImageCell"; //set some grid properties gridControl1.FloatCellsMode = GridFloatCellsMode.BeforeDisplayCalculation; gridControl1.AlphaBlendSelectionColor = Color.FromArgb(alphaBlendValue, Color.FromName("Highlight")); gridControl1.BorderStyle = BorderStyle.None; this.gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(7, 3, 10, 6)); this.gridControl1[7, 3].Borders.All = new GridBorder(GridBorderStyle.Solid, Color.Orange, GridBorderWeight.Thick); this.gridControl1[7, 3].Text = "Make some selections and then change the Excel-Like properties and selection color properties listed to the left."; this.gridControl1[7, 3].Font.Size = 9; this.gridControl1[7, 3].Font.Bold = false; this.gridControl1[7, 3].Font.Facename = "Helvetica"; this.gridControl1[7, 3].TextColor = Color.Orange; this.gridControl1[7, 3].Enabled = false; this.gridControl1[7, 3].VerticalAlignment = GridVerticalAlignment.Middle; this.gridControl1[7, 3].HorizontalAlignment = GridHorizontalAlignment.Left; //set default row height this.gridControl1.DefaultRowHeight = 22; }