Everything is ok. Check code in RED Color; When I click this button it opens a dialogue box and allows to select a file. Then the Selected file path appears in the adjoining cell i.e., 9th cell and 10th cell is the button.
What I am trying to achieve is when the cell 9 is empty the button image should be the initial one (that is AddButtonIcon from ImageList index 0) and if some path is available in that cell then Image should be another one (that is RemoveFileIcon from ImageList index 2).
How do we achieve this it's easily done in VB control like below;
Private Sub dataGridViewInspectionReportCertificateDetails_CellFormatting(ByVal sender As Object, ByVal e As DataGridViewCellFormattingEventArgs) Handles dataGridViewInspectionReportCertificateDetails.CellFormatting
ARAmal Raj U Syncfusion Team September 22, 2016 02:58 PM UTC
Thanks for using Syncfusion products.
We are able to understand the reported scenario. The reported scenario of changing ImageIndex of the button based on another cell value can be achieved using PrepareViewStyleInfo event. Please make use of the below code,
Thanks Amal. This only work in case of single button on entire grid. But if you see my code. Every row is having a button which get created every time we create a new row.
In that case its not working. it changes all button images.
I just want to change the button image where there is a value in cell next to it. All blank should be having other image.
ARAmal Raj U Syncfusion Team September 23, 2016 03:19 PM UTC
Thanks for the update.
We are able to understand your scenario with the provided information. If you are using a single button object for all cells in a column and change the image index for the button, then the image will be changed for all the cell buttons. So you must have different object for different buttons in the columns.
We suggest you to use the built-in PushButton cell type and draw the cell image for the PushButton with the specified condition to change the image. Please make use of the below code,