I'm trying to create row of check boxes. To do that I created custom cell element as described in the topic https://docs.telerik.com/devtools/winforms/controls/virtualgrid/cells/creating-custom-cells.
But after form resizing custom cells are displayed in wrong row.
Please find screenshot attached.
Is it a working way to implement row of custom cells in VirtualGrid?
Thank you in advance.
7 Answers, 1 is accepted
The UI building the RadVirtualGrid control is also virtualized, basically meaning that the visual elements are reused while scrolling. The screenshots indicate that custom cell is being used in a column in which it is not intended. Can you please check the IsCompatible method in the custom cell class in your project and make sure that it returning true only for the desired column. In case the issue persists, please share a code snippet demonstrating the result on your end so that I can test it.
I hope this will help.
Thank you for your reply.
I took a look on IsCompatible method. And it works fine for me. But issue still exists.
I would like to share a code snippet with you.
Used version of controls is 2017.1.221.40. Maybe this is a reason...
Thank you, Yuri
Looking at the code snippet and the screenshot, it appears that you are trying to create a custom cell only for a particular row and column in the grid. This way the grid ends up with different cells located in the same column. Because of reusing the elements, this leads to the described behavior. Please note that this is not supported and if you need custom cells, you will need to use them for the entire column. Then the IsCompatible method should only return true if the column index is the one you have specified and the row is data row.
As a possible solution, you can try creating a custom cell having different elements in it. This way you will be able to display one element inside the cell for some rows and other elements for other rows. I am attaching my test project demonstrating the suggested approach as well as a short video showing the result on my end.
Thank you for you reply.
I have tried your solution, but it slows down my grid where commonly displayed over 200 columns.
And I finished with another solution. It works for me fine.
I would like to share it. Could you please take a look and answer if you see something wrong?
Generally speaking, you need to be careful when instantiating objects in the CellFormating event. This event will be raised numerous times while running the application and initializing objects in it may increase the consumed memory. Otherwise, I see no other issues with your approach. You can consider caching the elements so that new RadCheckBoxElement objects are created for new rows which are raising the formatting event. In order to update the toggle state of the checkbox, I also had to use a flag and suspend the formatting. Please check my code snippet below:
I hope this will help. Let me know if you need further assistance.
Thank you very much for your reply, it worka for me perfect!
With the best regards, Yuri.
Thank you for the update. I am glad that the discussed approach is working well on your end. Let me know if you need further assistance.