private void SfDataGrid_DrawCell(object sender, DrawCellEventArgs e) { if (this.sfDataGrid.CurrentCell != null && this.sfDataGrid.CurrentCell.IsEditing) { return; } if (e.Column.MappingName == "Total" && e.DataRow.RowType == RowType.DefaultRow) { var value = (e.DataRow.RowData as SalesByYear).Total; var graphics = e.Graphics; var rect = e.Bounds; Rectangle rect1 = new Rectangle(rect.X + 15, rect.Y + 6, rect.Width / 6, rect.Height / 2); StringFormat format = new StringFormat(); if (value > 2500000) { ShapesPainter.DrawTriangle(graphics, rect1, TriangleDirection.Up, Brushes.Green, new Pen(Color.Green), true); graphics.DrawString(e.DisplayText, e.Style.Font.GetFont(), new SolidBrush(e.Style.TextColor), rect.X + 40, rect.Y + 5, format); } else { ShapesPainter.DrawTriangle(graphics, rect1, TriangleDirection.Down, Brushes.Red, new Pen(Color.Red), true); graphics.DrawString(e.DisplayText, e.Style.Font.GetFont(), new SolidBrush(e.Style.TextColor), rect.X + 40, rect.Y + 5, format); } Pen borderPen = new Pen(Brushes.LightGray); graphics.DrawLine(borderPen, rect.Right - 1, rect.Top, rect.Right - 1, rect.Bottom); graphics.DrawLine(borderPen, rect.Left, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1); e.Handled = true; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SfDataGrid_DrawCell(object sender, DrawCellEventArgs e) { if ((e.DataRow as DataRowBase).RowType == RowType.SummaryRow || (e.DataRow as DataRowBase).RowType == RowType.TableSummaryRow) { e.Style.HorizontalAlignment = HorizontalAlignment.Right; } }
private void ListDataGrid_DrawCell(object sender, DrawCellEventArgs e) { if (ShowRowHeader && e != null && e.RowIndex != 0) { if (e.ColumnIndex == 0) { e.DisplayText = e.RowIndex.ToString(); e.Style.TextColor = Color.Black; e.Style.VerticalAlignment = VerticalAlignment.Center; e.Style.HorizontalAlignment = HorizontalAlignment.Center; } } }
//Event customization private void SfDataGrid1_DrawCell(object sender, DrawCellEventArgs e) { if (e.Column.MappingName == "Hyperlink") { string displayText = e.DisplayText; int index = displayText.LastIndexOf('.'); int firstIndex = displayText.IndexOf('.'); int length = displayText.Length - (displayText.Length - index) - firstIndex; displayText = e.DisplayText.Substring(firstIndex + 1, length - 1); //To update text of hyperlink. e.DisplayText = displayText; } }
/// <summary> /// Event for Customize the date celll /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void MonthCalendar_DrawCell(SfCalendar sender, DrawCellEventArgs args) { DateTime Christmas = new DateTime(2017, 12, 25); DateTime Chris = new DateTime(2017, 12, 12); DateTime birthday = new DateTime(2018, 01, 26); DateTime farwell = new DateTime(2018, 01, 14); DateTime newyear = new DateTime(2018, 01, 01); if (args.Value != null) { if (args.Value == Christmas) { args.ForeColor = Color.Chocolate; args.ImageBounds = new Rectangle(2, 1, 24, 28); } if (args.Value == farwell) { args.ForeColor = Color.Brown; } if (args.Value == Chris) { args.ForeColor = Color.Red; } if (args.Value == newyear) { args.ForeColor = Color.Blue; } if (args.Value == birthday) { args.ForeColor = Color.GreenYellow; } } }
/// <summary> /// Used to customize the cell /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SfDataGrid_DrawCell(object sender, DrawCellEventArgs e) { if (this.sfDataGrid.CurrentCell != null && this.sfDataGrid.CurrentCell.IsEditing) { return; } if (e.Column.MappingName == "Change" && e.DataRow.RowType == RowType.DefaultRow) { var graphics = e.Graphics; var rect = e.Bounds; Rectangle rect1 = new Rectangle(rect.X + 20, rect.Y + 6, rect.Width / 6, rect.Height / 2); StringFormat format = new StringFormat(); e.Style.HorizontalAlignment = HorizontalAlignment.Center; var drawingObj = new DrawingHelper(); var value = drawingObj.GetType().GetMethod("ConvertToStringAlignment", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static, Type.DefaultBinder, new Type[] { typeof(HorizontalAlignment) }, new ParameterModifier[] { }).Invoke(drawingObj, new object[] { e.Style.HorizontalAlignment }); format.Alignment = (StringAlignment)value; var value1 = drawingObj.GetType().GetMethod("ConvertToStringAlignment", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static, Type.DefaultBinder, new Type[] { typeof(VerticalAlignment) }, new ParameterModifier[] { }).Invoke(drawingObj, new object[] { e.Style.VerticalAlignment }); format.LineAlignment = (StringAlignment)value1; if ((e.DataRow.RowData as StockData).Change > 0) { ShapesPainter.DrawTriangle(graphics, rect1, TriangleDirection.Up, Brushes.Green, new Pen(Color.Green), true); graphics.DrawString(e.DisplayText, e.Style.Font.GetFont(), new SolidBrush(Color.Green), rect.X + 92, rect.Y + 13, format); } else { ShapesPainter.DrawTriangle(graphics, rect1, TriangleDirection.Down, Brushes.Red, new Pen(Color.Red), true); graphics.DrawString(e.DisplayText, e.Style.Font.GetFont(), new SolidBrush(Color.Red), rect.X + 90, rect.Y + 13, format); } Pen borderPen = new Pen(Brushes.LightGray); graphics.DrawLine(borderPen, rect.Right - 1, rect.Top, rect.Right - 1, rect.Bottom); graphics.DrawLine(borderPen, rect.Left, rect.Bottom - 1, rect.Right, rect.Bottom - 1); e.Handled = true; } }
public RCellset(CellSet.CellSet cs, int maxTextLenght) { if (cs == null) { RowCount = 0; ColCount = 0; FixedRows = 0; FixedCols = 0; Cells = new RCell[0]; return; } RowCount = cs.PagedRowCount; ColCount = cs.PagedColumnCount; FixedRows = cs.FixedRows; FixedCols = cs.FixedColumns; TreeLikeBehavior = cs.Grid.HierarchiesDisplayMode == HierarchiesDisplayMode.TreeLike; var c1 = new HashSet <string>(); //impos = new Dictionary<string, ImagePosition>(); //images = new Dictionary<string, string>(); var cc = new List <RCell>(); for (var i = 0; i < cs.RowCount; i++) { if (!cs.Grid.CellSet.IsRowVisible(i)) { continue; } for (var j = 0; j < cs.ColumnCount; j++) { if (!cs.Grid.CellSet.IsColumnVisible(j)) { continue; } var c = cs[j, i]; if (c.ColSpan < 1 || c.RowSpan < 1) { continue; } if (c.ColSpan > 1 || c.RowSpan > 1) { var s = string.Format("{0}|{1}", c.StartColumn, c.StartRow); if (!c1.Add(s)) { continue; } } #if SL DrawCellEventArgs e = ((RiaOLAPControl)cs.Grid).OnDrawCell(c); RCell cell = new RCell(c, e); if (e != null && !string.IsNullOrEmpty(e.ImageUri)) { cell.BackImageUrl = e.ImageUri; cell.ImagePosition = e.ImagePosition; //impos.Add(index.ToString(), e.ImagePosition); //images.Add(index.ToString(), e.ImageUri); } #else var cell = new RCell(c); #endif cell.MaxTextLength = maxTextLenght; cc.Add(cell); } } Cells = cc.ToArray(); cs.Grid.InitClientCellset(this); }