Hi,
I had a datagridview (DGV) that I was assigning an image (from an imagelist). On reflection I wanted to make the DGV equal to a datatable (using a dataview). This was primarily to make filtering the contents easier. The problem I now have is that I can't assign the image to the DGV as the datatable I have doesn't have an imagecolumn, and I assign the datasource of the DGV = to the datatable.
I was thinking of solutions along the lines of:
1. Somehow create a column in my datatable and assign it a type "image" and then bind that column to the DataGridViewImageColumn (Haven't tried this so don't know if it will work). Downside is that every single row in my table will then have to store an image - and I'd rather just have these in my imagelist and reference them.
2. Maybe have an event on my datatable that when a row is added I then update the DGV row with the icon from the imagelist (I have tried this and it doesn't work - for some reason the DataTable.TableNewRow event doesn't return the data within the e parameter (which is a DataTableNewRowEventArgs)
Are there any other options? Surely this problem must exist for quite a few applications where a datatable is used as the datasource for a DGV. I simply want to use a column reference to update an icon from an imagelist.
Anybody got any ideas?
Thanks,
N
I had a datagridview (DGV) that I was assigning an image (from an imagelist). On reflection I wanted to make the DGV equal to a datatable (using a dataview). This was primarily to make filtering the contents easier. The problem I now have is that I can't assign the image to the DGV as the datatable I have doesn't have an imagecolumn, and I assign the datasource of the DGV = to the datatable.
I was thinking of solutions along the lines of:
1. Somehow create a column in my datatable and assign it a type "image" and then bind that column to the DataGridViewImageColumn (Haven't tried this so don't know if it will work). Downside is that every single row in my table will then have to store an image - and I'd rather just have these in my imagelist and reference them.
2. Maybe have an event on my datatable that when a row is added I then update the DGV row with the icon from the imagelist (I have tried this and it doesn't work - for some reason the DataTable.TableNewRow event doesn't return the data within the e parameter (which is a DataTableNewRowEventArgs)
Are there any other options? Surely this problem must exist for quite a few applications where a datatable is used as the datasource for a DGV. I simply want to use a column reference to update an icon from an imagelist.
Anybody got any ideas?
Thanks,
N