I used the Grid in the Telerik samples for WinUI C:\Program Files (x86)\Telerik\UI for WinForms Q1 2015\Examples\QuickStart\GridView\Rows\AddNewRow\Form1.cs and added the following code to get the UnitPrice in a blue font:
public Form1()
{
...
this.radGridView1.CellFormatting += new CellFormattingEventHandler(radGridView1_CellFormatting);
}
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
GridDataCellElement dataCell = e.CellElement as GridDataCellElement;
if (dataCell != null)
{
if (dataCell.ColumnInfo.Name.ToLower() == "unitprice")
{
dataCell.ForeColor = System.Drawing.Color.Blue;
dataCell.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
}
}
}
This works when the form get first loaded:
If I scroll the form vertically some of the other columns get blue too. Is there something I can do about this?
Customization should be reset for other columns
if (dataCell.ColumnInfo.Name.ToLower() == "unitprice")
{
dataCell.ForeColor = System.Drawing.Color.Blue;
dataCell.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
}
else
{
e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
}