Having set up a datagridview, bound to a bindingsource, I have to use the cellformatting to paint the cells various colours.
Since you cannot access a field or record via bindingsource on a cellformatting event, the only way I could access the data, is through a column such as the primary ID for example. (this is only for cellformatting, i have no problem accessing the ID through the bindignsource.current object).
So, once I have finished designing and testing my datagridview, I then switch various columns (ID) for this example, to visible=false to make the column invisible.
I now cannot access the column data through cellformatting. I have read on a number of pages listed by google that since datagridview doesnt render the columns, the values are unobtainable aside from a couple of alternatives such as : .TAG and datakeynames
I cannot find datakeynames under datagridview for winforms for some reason. .tag doesnt seem to do anything as far as I can tell.
Since trying to use this from the cell formatting, I am unable to use
Select Case .Columns(e.ColumnIndex).DataPropertyName.ToLower
or
If Datagridview1.columns(e.columnindex).datapropertyname.tolower='id' Then
as the column is invisible...
Shame I cannot access the bindingsource through cellformatting, but there must be a way and there must be others who have had this issue.