Code
Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Linq;
Using System. Text;
Using System. Windows. Forms;
Using Infragistics. Win;
Using Infragistics. Win. UltraWinGrid;
Namespace WindowsDataGrid
{
Public partial class Form1: Form
{
Public Form1 ()
{
InitializeComponent ();
}
Private void Form1_Load (object sender, EventArgs e)
{
DataTable dataTable = new DataTable ();
DataTable. Columns. Add ("GPNO", typeof (string ));
DataTable. Columns. Add ("Price", typeof (float ));
DataTable. Columns. Add ("Price2", typeof (float ));
DataTable. Rows. Add (new object [] {"54545", 1.02,-2.32 });
DataTable. Rows. Add (new object [] {"54522",-2.02, 1.2 });
DataTable. Rows. Add (new object [] {"54511", 3.02,-1.12 });
DataTable. Rows. Add (new object [] {"54512", 1.02,-2.32 });
DataTable. Rows. Add (new object [] {"54514",-2.02, 1.2 });
DataTable. Rows. Add (new object [] {"54513", 3.02,-1.12 });
Ultrabod1.datasource = able;
Ultrabod1.databind ();
}
Private void ultrabod=initializelayout (object sender, Infragistics. Win. UltraWinGrid. InitializeLayoutEventArgs e)
{
Ultrabodlayout layout = e. Layout;
Ultra'dband rootBand = layout. Bands [0];
Ultrabodoverride rootOverride = layout. Override;
RootBand. Columns ["Price"]. ValueBasedAppearance = CreateOperatorConditionValueAppearance (0 );
RootBand. Columns ["Price2"]. ValueBasedAppearance = CreateOperatorConditionValueAppearance (0 );
}
# Region CreateOperatorConditionValueAppearance
/// <Summary>
/// The cell dynamically changes color based on the data value
/// </Summary>
/// <Param name = "num"> </param>
/// <Returns> </returns>
Private ConditionValueAppearance CreateOperatorConditionValueAppearance (float num)
{
ConditionValueAppearance conditionValueAppearance = new ConditionValueAppearance ();
OperatorCondition negativeCondition = new OperatorCondition (ConditionOperator. LessThan, num );
Infragistics. Win. Appearance negativeAppearance = new Infragistics. Win. Appearance ("Negative ");
NegativeAppearance. ForeColor = Color. Green;
OperatorCondition positiveCondition = new OperatorCondition (ConditionOperator. greaterthanorcondito, num );
Infragistics. Win. Appearance positiveAppearance = new Infragistics. Win. Appearance ("Positive ");
PositiveAppearance. ForeColor = Color. Red;
ConditionValueAppearance. Add (negativeCondition, negativeAppearance );
ConditionValueAppearance. Add (positiveCondition, positiveAppearance );
Return conditionValueAppearance;
}
# Endregion CreateOperatorConditionValueAppearance
}
}