I am starting a new project and getting back to an old question.
My application will display the user some information in a DataGridView
. The DataGridView
will get its data from a database as DataTable
. The database-table contains a column called "icon" which is of the type Integer
. The column "icon" is referring to my Image Array()
-Index. So when item("icon").Equals(2)
then ImageArray(2) should be shown.
What is the best way, to make my DataGridView
display that icon instead of its index?
What I used to use in pseudocode;
Dim dt as DataTable = GetDataFromDatabase()
dt.columns.add("Icon")
For each row as DataRow in dt.Rows
row.item("Icon") = IconArray(row.Item("IconIndex"))
End For
dt.columns.remove("IconIndex")
MyDataGridView.DataSource = dt
Obviously this performes terribly when called every few seconds to keep the data up to date.
What I have also tried:
- Played around with the CellFormattingEvent
- Played around with DisplayValue-Attribute