Hi Nathaniel,
Thank you for your interest in Syncfusion products.
You can update the image index of a cell which contains their cell type as “Image” through “PrepareViewStyleInfo” event, when new conditions are met. In the given sample, the image will change when the first column value is changed.
public Form1()
{
InitializeComponent();
this.gridControl1.ColStyles[2].CellType = "Image";
this.gridControl1.ColStyles[2].ImageList = this.imageList1;
this.gridControl1.ColStyles[2].ImageSizeMode = Syncfusion.Windows.Forms.Grid.GridImageSizeMode.StretchImage;
this.gridControl1.ColStyles[1].CellValueType = typeof(int);
this.gridControl1.DefaultRowHeight = 64;
this.gridControl1.RowCount = this.imageList1.Images.Count;
for (int i = 0; i < this.gridControl1.RowCount; i++)
{
this.gridControl1[i + 1, 1].CellValue = i;
}
this.gridControl1.PrepareViewStyleInfo += new Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventHandler(gridControl1_PrepareViewStyleInfo);
}
int[] index = new int[20];
void gridControl1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
if (e.ColIndex == 1)
{
if (e.Style.CellValue.ToString() != string.Empty && int.Parse(e.Style.CellValue.ToString()) < this.imageList1.Images.Count)
{
index[e.RowIndex] = int.Parse(e.Style.CellValue.ToString()); // save the changes
this.gridControl1.RefreshRange(GridRangeInfo.Cell(e.RowIndex, 2)); // refresh the adjacent cell to raise the event once again.
}
}
if (e.ColIndex == 2 && e.Style.CellType == "Image")
{
e.Style.ImageIndex = index[e.RowIndex]; // set the image index.
}
}
Please refer the sample in the below link.
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GC_ImageIndex-1700992398.zipPlease let me know if you have any other concerns.
Regards,
Christo