Change text color in datagrid (windows form) depending on value of other column
Posted on 2006-03-27
I have a datagrid where I display some columns. This datagrid is based on a dataset, one of the columns of this dataset is Color, where the numerical value of the color is stored (e.g. 255 for red). My question now is : how can I set the fontcolor of my columns to that stored column. I have already created a class 'ColoredDataGridColumn' that I inherited from DataGridTextBoxColumn, and I created a sub Paint in the class:
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal source As CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean)
My problem is now : how do I know the color that is stored in the column ?
I already examined the code that changes the background to pink if the first character is bigger than "F", and this works, but this is a very static test.