….
sfdataGrid.CellRenderers.Remove("TextView");
sfdataGrid.CellRenderers.Add("TextView", new CustomTextViewRenderer());
…
public class CustomTextViewRenderer : GridCellTextViewRenderer
{
public CustomTextViewRenderer()
{
}
protected override void OnRefreshDisplayValue(DataColumnBase dataColumn)
{
base.OnRefreshDisplayValue(dataColumn);
}
protected override void OnLayout(RowColumnIndex rowColumnIndex, View view, int left, int top, int right, int bottom)
{
var rowData = ((view as GridCell).DataColumn.RowData as DataRowView).Row.Table.Rows[rowColumnIndex.RowIndex - 1];
base.OnLayout(rowColumnIndex, view, left, top, right, bottom);
var count = rowData.Table.Columns.Count;
for (int i = 0; i <= count - 1; i++)
{
if (rowData.ItemArray[i].ToString().Contains("3") || rowData.ItemArray[i].ToString().Contains("8") )
{
(view.Parent as View).SetBackgroundColor(Color.Green);
}
}
}
} |