I am trying to change the color of the rows whose ID is less than 5. But this is not working. I am trying to use the NorthWind Dataset. Can anyone help in finding the problem.
Here is the code:
namespace Sample_UltraGrid
{
public partial class Form1 : Form
public Form1()
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
this.ordersTableAdapter.Fill(this.nwindDataSet.Orders);
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
// Create an appearance for values which are less than 5
Infragistics.Win.Appearance lessThan = e.Layout.Appearances.Add("Less");
lessThan.ForeColor = Color.Red;
// Create an appearance for values which are greater than 5
Infragistics.Win.Appearance greaterThan = e.Layout.Appearances.Add("Greater");
greaterThan.ForeColor = Color.Green;
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
UltraGrid grid = (UltraGrid)sender;
// Get the value of the EmployeeID column.
UltraGridColumn employeeIDColumn = this.ultraGrid1.DisplayLayout.Bands[0].Columns["EmployeeID"];
int ID = (int)e.Row.GetCellValue(employeeIDColumn);
if (ID < 5)
// Use the Negative Appearance already defined in the grid's Appearances collection.
e.Row.Cells["EmployeeID"].Appearance = grid.DisplayLayout.Appearances["Less"];
else
// Use the Positive Appearance already defined in the grid's Appearances collection.
e.Row.Cells["EmployeeID"].Appearance = grid.DisplayLayout.Appearances["Greater"];
If that line of code is getting hit and the colors are still not applying to the rows, then something else in your application must be setting another Appearance property which is overriding them. Perhaps you are applying a RowCellAppearance or setting the Appearance on each cell somewhere else in the app.
Ohh yeah.. I got where the hook up problem is ? But still the color is not applying to the rows..
There are rows. And I can view them. The Code in the InitializeLayout event is working and its effecting the rows and data in the table.
I have given my code. Can you please have a look at it and let me know why my InitializeRow event is not getting executed. I mean the hook up problem as u said.
If you are not even getting into the InitalizeRow event, then either your grid has no rows, the grid rows are not visible, or your event handler is not hooked up to the grid properly.
I tried it, Its not breaking at that point. What could be the reason?