/// <summary> /// QueryCellStyleInfo event : To Format Cell by Cell Basis on demand /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if (e.Style.CellValueType != null && e.Style.CellValueType == typeof(DateTime)) { e.Style.Format = "M/d/yyyy"; } if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell) { if (e.TableCellIdentity.ColIndex % 2 == 0) { e.Style.BackColor = Color.FromArgb(255, 187, 111); e.Style.Font.FontStyle = FontStyle.Bold; } else { e.Style.TextColor = Color.White; e.Style.BackColor = Color.FromArgb(55, 91, 114); } } else if (e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell) { if (e.TableCellIdentity.ColIndex % 2 == 0) { e.Style.Font.FontStyle = FontStyle.Underline; e.Style.BackColor = Color.FromArgb(0, 21, 84); e.Style.TextColor = Color.White; } else { e.Style.BackColor = Color.FromArgb(255, 188, 112); e.Style.Font.FontStyle = FontStyle.Italic; } } }
// QueryCellInfo even is hooked to set the values. private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { switch (e.TableCellIdentity.TableCellType) { case GridTableCellType.RecordPreviewCell: { GridGroupingControl groupingControl = (GridGroupingControl)sender; GridTable table = groupingControl.Table; GridRecord record = e.TableCellIdentity.DisplayElement.ParentRecord as GridRecord; if (record != null) { e.Style.CellValue = record.GetValue("Notes").ToString(); } else { e.Style.CellValue = "No Notes."; } break; } } StringBuilder sb = new StringBuilder(); sb.Append(e.TableCellIdentity.Info); if (e.Style != null) { sb.AppendFormat("\r\nCellType = {0}", e.Style.CellType); sb.AppendFormat(", CellValueType = {0}", e.Style.CellValueType); sb.AppendFormat(", nFormat = \"{0}\"", e.Style.Format); sb.AppendFormat(", CellValue = \"{0}\"", e.Style.CellValue); sb.AppendFormat(", ImageSizeMode = \"{0}\"", e.Style.ImageSizeMode); } e.Style.CellTipText = sb.ToString(); }
private void GGCPersLiq_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "fecha") { e.Style.Format = "MM/dd/yyyy"; } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "monto") { e.Style.Format = "#,##.00"; } if (e.Style.TableCellIdentity.Column != null && (e.Style.TableCellIdentity.Column.Name == "ID" || e.Style.TableCellIdentity.Column.Name == "Estado")) { if (e.TableCellIdentity.DisplayElement != null && e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record) { DataRowView dr1 = e.TableCellIdentity.DisplayElement.ParentRecord.GetData() as DataRowView; if (dr1 != null && dr1[9].ToString() == "Abierta") { e.Style.TextColor = Color.Yellow; e.Style.BackColor = Color.SteelBlue; } if (dr1 != null && dr1[9].ToString() == "Cerrada Normal") { e.Style.TextColor = Color.Green; } if (dr1 != null && dr1[9].ToString() == "Cerrada con faltante") { e.Style.TextColor = Color.Red; } if (dr1 != null && dr1[9].ToString() == "Cerrada con sobrante") { e.Style.TextColor = Color.SteelBlue; } } } }
private void GGCPersLiq_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "fecha") { e.Style.Format = "MM/dd/yyyy"; } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "FechaER") { e.Style.Format = "MM/dd/yyyy"; } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "Total") { e.Style.Format = "#,##.00"; } if (e.TableCellIdentity.DisplayElement != null && e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record) { if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "Ab") { DataRowView dr1 = e.TableCellIdentity.DisplayElement.ParentRecord.GetData() as DataRowView; if (dr1 != null && dr1[2].ToString() == "S/.") { e.Style.TextColor = Color.SteelBlue; } else { e.Style.TextColor = Color.Green; } } } if (e.TableCellIdentity.DisplayElement != null && e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record) { if (e.Style.TableCellIdentity.Column != null && ((e.Style.TableCellIdentity.Column.Name == "Documento") || (e.Style.TableCellIdentity.Column.Name == "Total") || (e.Style.TableCellIdentity.Column.Name == "Detalle"))) { DataRowView dr1 = e.TableCellIdentity.DisplayElement.ParentRecord.GetData() as DataRowView; if (dr1 != null && dr1[7].ToString() == "Compras/Pagos realizados") { e.Style.TextColor = Color.SteelBlue; } else { if (dr1 != null && dr1[7].ToString() == "Se uso en otra EAR") { e.Style.TextColor = Color.Green; } else { e.Style.TextColor = Color.Navy; } } } } }
//set the custom styles to the cells private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordPreviewCell) { Element el = e.TableCellIdentity.DisplayElement; e.Style.CellValue = "Preview notes for Record (" + el.ParentTableDescriptor.Fields[0].Name + ": " + el.ParentRecord.GetValue(el.ParentTableDescriptor.Fields[0].Name) + ")"; } if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupPreviewCell) { Element el = e.TableCellIdentity.DisplayElement; e.Style.CellValue = "Preview notes for Group (" + el.ParentGroup.Name + ": " + el.ParentGroup.Category.ToString() + ")"; } }
private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupFooterSectionCell || e.TableCellIdentity.TableCellType == GridTableCellType.GroupHeaderSectionCell) { e.Style.BackColor = Color.LightSeaGreen; e.Style.Enabled = false; if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupFooterSectionCell) { e.Style.Text = "The details in the footer can be placed by enabling ShowGroupFooter and handling QueryCellStyleInfo"; } if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupHeaderSectionCell) { e.Style.Text = "The details in the header can be placed by enabling ShowGroupHeader and handling QueryCellStyleInfo"; } } }
//Used to setup the cell-specific formatting information private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { switch (e.TableCellIdentity.TableCellType) { case GridTableCellType.RecordPreviewCell: { GridGroupingControl groupingControl = (GridGroupingControl)sender; GridTable table = groupingControl.Table; GridRecord record = (GridRecord)e.TableCellIdentity.DisplayElement.ParentRecord; e.Style.CellValue = record.GetValue("Notes").ToString(); break; } case GridTableCellType.AlternateRecordFieldCell: case GridTableCellType.AddNewRecordFieldCell: case GridTableCellType.RecordFieldCell: { GridTable table = e.TableCellIdentity.Table; string tableName = table.TableDescriptor.Name; GridRecord record = (GridRecord)e.TableCellIdentity.DisplayElement.ParentRecord; object recordkey = record.PrimaryKeys[0]; string fieldName = e.TableCellIdentity.Column.MappingName; GridStyleInfo style = GetCellStyle(tableName, recordkey, fieldName); if (style != null) { e.Style.ModifyStyle(style, Syncfusion.Styles.StyleModifyType.Override); } break; } } StringBuilder sb = new StringBuilder(); sb.Append(e.TableCellIdentity.Info); if (e.Style != null) { sb.AppendFormat("\r\nCellType = {0}", e.Style.CellType); sb.AppendFormat(", CellValueType = {0}", e.Style.CellValueType); sb.AppendFormat(", nFormat = \"{0}\"", e.Style.Format); sb.AppendFormat(", CellValue = \"{0}\"", e.Style.CellValue); sb.AppendFormat(", ImageSizeMode = \"{0}\"", e.Style.ImageSizeMode); } e.Style.CellTipText = sb.ToString(); }
private void GGCPersLiq_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "precioventa") { e.Style.Format = "#,##.00"; } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "cantidad") { e.Style.Format = "#,##.00"; } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "Total") { e.Style.Format = "#,##.00"; } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "Registro") { e.Style.Format = "MM/dd/yyyy"; } }
private void GGCPersLiq_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "Constancia") { //Setting the comment tip text if (e.TableCellIdentity.DisplayElement != null && e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record) { DataRowView dr1 = e.TableCellIdentity.DisplayElement.ParentRecord.GetData() as DataRowView; if (dr1 != null && dr1[2].ToString() == "NO") { e.Style.BackColor = Color.Red; e.Style.TextColor = Color.WhiteSmoke; } } } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "vencimiento") { e.Style.Format = "MM/dd/yyyy"; } }
private void GGCVista_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if (e.TableCellIdentity.TableCellType != GridTableCellType.ColumnHeaderCell) { if (e.Style.CellValue != null && e.Style.Text != "") { if (e.TableCellIdentity.ColIndex != 0) { if (e.TableCellIdentity.DisplayElement.ParentRecord != null) { DataRowView dr = e.TableCellIdentity.DisplayElement.ParentRecord.GetData() as DataRowView; if (dr != null && Convert.ToInt16(dr[4].ToString()) != 0) { e.Style.BackColor = Color.Green; e.Style.TextColor = Color.WhiteSmoke; } } } } } }
void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { // Disable Border Line e.Style.Borders.Right = GridBorder.Empty; e.Style.Borders.Bottom = GridBorder.Empty; if (e.Style.CellType == "ColumnHeaderCell") { e.Style.Enabled = false; e.Handled = false; } // Adding Weather Condition images if (e.TableCellIdentity.ColIndex == 2 && e.TableCellIdentity.RowIndex != 1) { if (e.Style.Text == "Rainy") { e.Style.CellType = "Control"; e.Style.Control = pb; } else if (e.Style.Text == "Rainy Storm" || e.Style.Text == "Cloudy") { e.Style.CellType = "Control"; e.Style.Control = pb2; } else if (e.Style.Text == "Snow") { e.Style.CellType = "Control"; e.Style.Control = pb1; } else { e.Style.CellType = "Control"; e.Style.Control = pb3; } } }
private void GGCPersLiq_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "TD") { if (e.TableCellIdentity.DisplayElement != null && e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record) { DataRowView dr1 = e.TableCellIdentity.DisplayElement.ParentRecord.GetData() as DataRowView; if (dr1 != null && dr1[19].ToString() == "0") { e.Style.BackColor = Color.Green; e.Style.TextColor = Color.WhiteSmoke; } else { e.Style.BackColor = Color.WhiteSmoke; e.Style.TextColor = Color.Green; } } } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "Total") { e.Style.Format = "#,##.00"; } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "TC") { e.Style.Format = "#,##.000"; } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "Soles") { e.Style.Format = "#,##.00"; } if (e.TableCellIdentity.DisplayElement != null && e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record) { DataRowView dr1 = e.TableCellIdentity.DisplayElement.ParentRecord.GetData() as DataRowView; if (dr1 != null && dr1[16].ToString() == "1") { e.Style.BackColor = Color.Red; e.Style.TextColor = Color.WhiteSmoke; } } if (e.TableCellIdentity.DisplayElement != null && e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record) { DataRowView dr1 = e.TableCellIdentity.DisplayElement.ParentRecord.GetData() as DataRowView; if (dr1 != null && dr1[32].ToString() == "Si") { e.Style.BackColor = Color.Green; e.Style.TextColor = Color.WhiteSmoke; } } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "Moneda") { if (e.TableCellIdentity.DisplayElement != null && e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record) { DataRowView dr1 = e.TableCellIdentity.DisplayElement.ParentRecord.GetData() as DataRowView; if (dr1 != null && dr1[12].ToString() == "Soles") { e.Style.BackColor = Color.AliceBlue; e.Style.TextColor = Color.SteelBlue; } else { e.Style.BackColor = Color.White; e.Style.TextColor = Color.Green; } } } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "TArchivo") { if (e.TableCellIdentity.DisplayElement != null && e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record) { DataRowView dr1 = e.TableCellIdentity.DisplayElement.ParentRecord.GetData() as DataRowView; if (dr1 != null && dr1[34].ToString() == "Si") { e.Style.BackColor = Color.Green; e.Style.TextColor = Color.White; } else { e.Style.BackColor = Color.Red; e.Style.TextColor = Color.White; } } } }
private void GGCDetalle_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if (e.Style.TableCellIdentity.Column != null) { //Setting the comment tip text if (e.TableCellIdentity.DisplayElement != null && e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record) { DataRowView dr1 = e.TableCellIdentity.DisplayElement.ParentRecord.GetData() as DataRowView; if (dr1 != null && dr1[9].ToString() == "1") { if (dr1 != null && dr1[8].ToString() == "0") { e.Style.BackColor = Color.Red; e.Style.TextColor = Color.WhiteSmoke; e.Style.Font.Bold = true; } if (dr1 != null && dr1[8].ToString() == "1") { e.Style.BackColor = Color.Black; e.Style.TextColor = Color.WhiteSmoke; e.Style.Font.Bold = true; } if (dr1 != null && dr1[8].ToString() == "2") { e.Style.BackColor = Color.Green; e.Style.TextColor = Color.WhiteSmoke; e.Style.Font.Bold = true; } if (dr1 != null && dr1[8].ToString() == "3") { e.Style.BackColor = Color.SteelBlue; e.Style.TextColor = Color.WhiteSmoke; e.Style.Font.Bold = true; } if (dr1 != null && dr1[8].ToString() == "4") { e.Style.BackColor = Color.DarkCyan; e.Style.TextColor = Color.WhiteSmoke; e.Style.Font.Bold = true; } if (dr1 != null && dr1[8].ToString() == "5") { e.Style.BackColor = Color.Maroon; e.Style.TextColor = Color.WhiteSmoke; e.Style.Font.Bold = true; } } } } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "Metrado") { e.Style.Format = "#,##.00"; } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "Precio") { e.Style.Format = "#,##.00"; } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "Parcial") { e.Style.Format = "#,##.00"; } if (e.Style.TableCellIdentity.Column != null && e.Style.TableCellIdentity.Column.Name == "It") { e.Style.HorizontalAlignment = GridHorizontalAlignment.Right; } }