private void button_Clicked(object sender, EventArgs e)
{
foreach (RecordEntry record in dataGrid.View.Records)
{
foreach (var column in dataGrid.Columns)
{
var cellValue = dataGrid.GetCellValue(record.Data, column.MappingName);
}
}
} |
//Main Page
Style style = new Style(typeof(GridCell));
style.Setters.Add(new Setter() { Property = GridCell.BackgroundColorProperty, Value = newBinding() { Path = "OrderID", Converter = new Converter() } });
foreach (var column in sfGrid.Columns)
{
if (column.MappingName == "OrderID")
column.CellStyle = style;
}
//Converter class
public class Converter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var data = (int)value;
if (data == 10004)
return Color.Blue; // You can achieve your requirement here.(applying styles for particular cell based on the cell value)
return Color.Default;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
} |
sfGrid.GridViewCreated += SfGrid_GridViewCreated;
private void SfGrid_GridViewCreated(object sender, GridViewCreatedEventArgs e)
{
SfDataGrid dg = (SfDataGrid)sender;
//get the max items and min items from Grid for each column
List<int[]> maxList = GetColumnValue(dg, true);
List<int[]> lowList = GetColumnValue(dg, false);
//highlight the cells
HighLightCells(dg, lowList, true);
HighLightCells(dg, maxList, false);
} |