I have 4 columns in RadGridView.
column1 ---> ImageColumn
column2---> textColumn ---> hidden column
column3--->textColumn ----> hidden column
Based on the value in the text column (column2) i want to change the image in the (column0).
Based on the value in the text column (column3) i want to change the image in the (column1).
Most probably i have 5 different values comming into each textColumn.
Currently i implemented this by handling viewRowformatting event .
I see a drastic sluggish when user scrolls through the Gridview. Please suggest a better way to do this.
6 Answers, 1 is accepted
Thank you for contacting us.
The bottleneck when using images is the loading time. I suggest you loading all images before processing the gird. In addition, the CellFormatting event is a better place to customize cells. Please consider the following sample code:
Should you have any further questions, feel free to write us back.
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thank you for the solution. I missed that imagelist part. Awesome and wonderfull.
I use the WinForms version 726. The event CellFormatting fires correctly. But the entry of an image in the cell does not work. It does not display the graphic. Is there a bug in the version?
Here is an excerpt from my code:
Your question has already been answered in the support thread you've opened. Please, see our answer there for more information.
We kindly ask you to use just one support channel to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one. Moreover threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.
Thank you for your understanding.Kind regards,
the Telerik team
I added GridViewImageColumn to my grid
and then on grid_CellFormatting I wrote below code
if (e.Column.Name == "StatusDescription")
PreOrders order = (PreOrders)e.Row.DataBoundItem;
e.CellElement.ImageLayout = ImageLayout.Center;
e.CellElement.Image = null;
e.CellElement.Image = Properties.Resources.Send;
e.CellElement.Image = Properties.Resources.errorImage;
e.CellElement.Image = Properties.Resources.sendSuccesfully;
which set suitable image depends on condition to cell
but the image does not shown immediately and need to up-down on row or go out from cell
what should I do to solve the problem
You can try to subscribe to the CellFormatting event at an earlier point of time e.g. at design time, or prior setting/adding the grid's DataSource/Rows.
Also, the grid.Invalidate() call should not be added in this event, so you can remove it.
If you still have issues, please open a support ticket and provide us with a project we can reproduce the experienced issue and we will look into it.
I hope this helps.