r3nder
asked on
programatically retrieving images in resources
I am getting an invalid cast - I was wondering if this is even possible or is there a better way to do this
private void dgvCurrentUnSerialized_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
for (int i = 0; i < dgvCurrentUnSerialized.Rows.Count; i++)
{
DataGridViewImageCell cell = dgvCurrentUnSerialized.Rows[i].Cells[0] as DataGridViewImageCell;
var value = "(System.Drawing.Image)Properties.Resources._" + Convert.ToString(dgvCurrentUnSerialized.Rows[i].Cells[5].Value) + "_sm";
cell.Value = value;
}
}
ASKER
yes but how? is the question. How do I dynamically get an item from the resource table if I want to "build" the name of the resource
What do you have? A resource file with images inside or the images in the project as embedded resource?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes it is embedded in the resources file - I am on my way to work - so I will try it
ASKER
Worked perfect ....thank you Alexandre
As far as I understood from the code, the cell has the image name and you want to use it to get the image from an embedded resource?