>Good day all,
>I want to change the forecolor in a grid based on a criteria. The grid contains 5 column, the fifth column contains numbers between 1 to 5. The color changed based on the number
> eg 1 - blue/white
> 2 - green/white
> 3 - red/white etc.
>
You would use the DynamicForeColor property of the grid to accomplish this.
You could put in the form's init, the following code:
MyColor="IIF(Thisform.grdGrid1.Column5.Text1=1,RGB(0,0,255),;
IIF(Thisform.grdGrid1.Column5.Text1=2,RGB(0,255,0),;
IIF(Thisform.grdGrid1.Column5.Text1=3,RGB(255,0,0),;
IIF(Thisform.grdGrid1.Column5.Text1=4,RGB(255,0,0),;
IIF(Thisform.grdGrid1.Column5.Text1=5,RGB(255,0,0),RGB(0,0,0))))))"
Thisform.grdGrid1.SetAll("DynamicForeColor",MyColor,"Column")
The DynamicForeColor is evaluated for each row and not the whole grid at a time.
Hope this helps.
-----------------------------------------
Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.comwww.prenia.comWeblog: blogs.prenia.com/cathi