……..
GridNumericColumn orderIdColumn = new GridNumericColumn(); orderIdColumn.MappingName = "OrderID";
orderIdColumn.UserCellType = typeof(CustomCell);
GridNumericColumn employeeIdColumn = new GridNumericColumn();
employeeIdColumn.MappingName = "EmployeeID";
employeeIdColumn.UserCellType = typeof(CustomCell);
GridTextColumn lastNameColumn = new GridTextColumn();
lastNameColumn.MappingName = "LastName";
lastNameColumn.HeaderText = "LastName";
lastNameColumn.UserCellType = typeof(CustomCell);
_dataGrid.Columns.Add(lastNameColumn);
_dataGrid.Columns.Add(orderIdColumn);
_dataGrid.Columns.Add(employeeIdColumn);
………… public class CustomCell : GridCell {
TextView textView;
public CustomCell(Context context) : base(context)
{
textView = new TextView(this.Context);
textView.TextAlignment = TextAlignment.Center;
this.AddView(textView);
}
protected override void UnLoad()
{
if (this.Parent != null)
(this.Parent as VirtualizingCellsControl).RemoveView(this);
}
protected override void OnLayout(bool change, int l, int t, int r, int b)
{
this.textView.Layout(0, 0, this.Width, this.Height);
}
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
if ((DataColumn.RowData as OrderInfo).OrderID == 10001)
{
var font = Typeface.CreateFromAsset(Helpers.aqssetManager, "StrikeOut.otf");
textView.Typeface = font;
}
else if (textView.Typeface != null)
{
textView.Typeface = null;
}
this.textView.Text = DataColumn.CellValue.ToString();
}
} |
private void _dataGrid_AutoGeneratingColumn(object sender, AutoGeneratingColumnEventArgs e)
{
e.Column.UserCellType = typeof(CustomCell);
} |
if ((DataColumn.RowData as System.Data.DataRowView).Row.ItemArray[1].ToString() == "10001")
{
var font = Typeface.CreateFromAsset(Helpers.aqssetManager, "StrikeOut.otf");
textView.Typeface = font;
} |