private void DataGrid_QueryCellStyle(object sender, QueryCellStyleEventArgs e) { try { if (e.ColumnIndex == 4 && e.CellValue == null) { e.Style.BackgroundColor = Color.IndianRed; e.Style.ForegroundColor = Color.White; } else if (e.ColumnIndex == 4 && int.Parse(e.CellValue.ToString()) >= 0) { e.Style.BackgroundColor = Color.YellowGreen; e.Style.ForegroundColor = Color.White; } e.Handled = true; } catch { if (e.ColumnIndex == 4) { e.Style.BackgroundColor = Color.IndianRed; e.Style.ForegroundColor = Color.White; e.Handled = true; } } }
private void DataGrid_QueryCellStyle(object sender, QueryCellStyleEventArgs e) { if (e.Column.MappingName == "Name") { e.Style.FontAttribute = FontAttributes.Bold; e.Handled = true; } }
private void DataGrid_QueryCellStyle(object sender, QueryCellStyleEventArgs e) { if (e.ColumnIndex == 4) { e.Style.BackgroundColor = Color.FromRgb(225, 245, 254); } e.Handled = true; }
//protected override void OnAppearing() //{ // base.OnAppearing(); // App.MasterDashboardPage = this; //} private void DataGrid_QueryCellStyle(object sender, QueryCellStyleEventArgs e) { if (e.ColumnIndex == 1 && e.CellValue.ToString() == "4") { e.Style.BackgroundColor = Color.YellowGreen; e.Style.ForegroundColor = Color.White; } e.Handled = true; }
/// <summary> /// Triggers when a cell comes to the View /// </summary> /// <param name="sender">DataGrid_QueryCellStyle event sender</param> /// <param name="e">DataGrid_QueryCellStyle event args e</param> private void DataGrid_QueryCellStyle(object sender, QueryCellStyleEventArgs e) { if (e.ColumnIndex == 3 || (this.DataGrid.GetUnboundRowAtRowIndex(e.RowIndex) != null && this.DataGrid.GetUnboundRowAtRowIndex(e.RowIndex).Position == UnboundRowsPosition.FixedBottom)) { e.Style.BackgroundColor = Color.FromRgb(225, 245, 254); } e.Handled = true; }
private void dgPiutang_QueryCellStyle(object sender, QueryCellStyleEventArgs e) { if (e.Column.MappingName == "selisih") { var cellValue = e.DisplayText == null ? string.Empty : e.DisplayText.ToString(); float value = float.Parse(cellValue); if (value < 0) { e.Style.BackColor = Color.Pink; } } }
private void SfDataGrid_QueryCellStyle(object sender, QueryCellStyleEventArgs e) { if (e.Column.MappingName == "Status") { if (e.DisplayText.ToString() == "Active") { e.Style.TextColor = Color.Green; } else { e.Style.TextColor = Color.Red; } } }
static private void DataGrid_QueryCellStyle(object sender, QueryCellStyleEventArgs e) { if (e.ColumnIndex == 5 && e.RowIndex % 2 == 1) //black for every other end total { e.Style.BackgroundColor = Color.Black; e.Style.ForegroundColor = Color.Black; } if (e.ColumnIndex == 6 && e.RowIndex % 2 == 1) //black for every other runnig total { e.Style.BackgroundColor = Color.Black; e.Style.ForegroundColor = Color.Black; } e.Handled = true; }
private void SfDataGrid_QueryCellStyle(object sender, QueryCellStyleEventArgs e) { double value = (e.DataRow.RowData as SalesByYear).QS2; if (value < 300000 && e.ColumnIndex == 2) { e.Style.BackColor = Color.LightGoldenrodYellow; } if (value < 200000 && e.ColumnIndex == 3) { e.Style.BackColor = Color.LightBlue; } if (value < 400000 && e.ColumnIndex == 4) { e.Style.BackColor = Color.RosyBrown; } }
private void SfDataGrid_QueryCellStyle(object sender, QueryCellStyleEventArgs e) { double qS2 = (e.DataRow.RowData as SalesByYear).QS2; double qS3 = (e.DataRow.RowData as SalesByYear).QS3; double qS4 = (e.DataRow.RowData as SalesByYear).QS4; if (e.Column.MappingName == "QS2" && qS2 < 300000.00 && qS2 > 100000.00) { e.Style.BackColor = Color.LightGoldenrodYellow; } if (e.Column.MappingName == "QS3" && qS3 < 500000.00 && qS3 > 300000.00) { e.Style.BackColor = Color.LightBlue; } if (e.Column.MappingName == "QS4" && qS4 < 600000.00 && qS4 > 300000.00) { e.Style.BackColor = Color.RosyBrown; } }
/// <summary> /// Pretty print each row /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void sfDataGrid_QueryCellStyle(object sender, QueryCellStyleEventArgs e) { int index = e.RowIndex - 1; //do not paint the header if (index == -1) { return; } //custom cell style e.Style.TextMargins = new Padding(3, 3, 3, 3); e.Style.Font = new Syncfusion.WinForms.DataGrid.Styles.GridFontInfo(new Font("Segoe UI", 13, FontStyle.Regular, GraphicsUnit.Point)); //check to make sure the row data is valid if (e.DataRow.RowData is SelectableTaskDecorator st) { //paint the background to the task color if (e.Column.MappingName != "Selected") { e.Style.BackColor = st.DrawColor; } } }
private void dataGrid_QueryCellStyle(object sender, QueryCellStyleEventArgs e) { //e.Style.BackgroundColor = Color.Black; //e.Style.ForegroundColor = Color.White; //e.Handled = true; }