I am exploring various ways of setting images to a row and cell in a row in winultra grid.
I have a grid with bound columns . The values will be verified dynamically and if any cell/ Row is found to have errors, an error image should be displayed in row/cell appropriately.
Following is the approach I follow
1. In the grid_InitializeLayout, I set the following properties for e.Layout.Override(o)
a. o.DataErrorRowSelectorAppearance.Image = <error Image>
b. o.DataErrorRowAppearance.BackColor = System.Drawing.Color.LightYellow;
c. o.DataErrorCellAppearance.Image = <error Image>
d. o.DataErrorCellAppearance.ImageHAlign = HAlign.Left;
e. o.DataErrorCellAppearance.BackColor = System.Drawing.Color.LightYellow;
2. In grid_aftercellupdate, I am verifying the value of the cell and based on the validations, if I find an error, I am calling the following statement to mark an error
a. ((DataRowView)cell.Row.ListObject).Row.SetColumnError(cell.Column.Key, msg)
This shows the image in the required cell. As the image is displayed only in the cell having errors, I suppose that some appearance properties in the cell should contain the image that was being displayed. I have verified the following properties of the cell in the row
I. ActiveAppearance.Image
II. Appearance.Image
III. SelectedAppearance.Image
But all of them are null even though the cell displays the image. Can you let me know from which properties of the cell, I can retrieve the image displayed. I am sure that some property of the cell will contain the image as it will be shown only for the cells with errors. Similarly, can you let me know how to retrieve the image from the row when there is an error.
Hello tsatish,
Thank you for contacting me again.
Accessing the Appearance.Image of the cell would give you the image if such is set and not the ErrorImage. You could set an image and an error image, so these images are different.
Could you please describe your scenario in details, such what is the reason you are trying to access the error image by certain cell. Do you want to set another error image for the cell or to know if there is an error image in the cell?
Hi Boris,
Thanks for the reply.
We can retrieve the image from this property irrespective of whether the cell has error or not.
My requirement is like this.
I have 5 rows in the grid out of which the first 3 cells have data error and the error image is displayed only in those cells. The other 2 cells doesnt display any image.
I want to access a property for the cell such that the image will be available only if the cell displays the image.
I need a similar property for row also. An error is displayed in the rowselector area for rows having errors.
Please let me know if there are any such properties available.
Please let me know if there is any confusion in the requirement I need.
You could get the image displayed using the following approach:
e.Cell.Column.Layout.Override.DataErrorCellAppearance.Image;
Since the image is set for all cells in the column, it could be accessed by the 'DataErrorCellAppearance'.
Please do not hesitate to contact us if you need any additional assistance.