This is a migrated thread and some comments may be shown as answers.

custom item creation from an object list

2 Answers 74 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Alvin
Top achievements
Rank 1
Alvin asked on 05 Dec 2011, 02:40 AM
Hi,

I have few questions about how to create custom item in RadListView.

I have a list of objects and would like to create custom item for each of the object. The value of visualElements of each custom item will get from properties value of associated object.

By reading the online documents, I know that the custom visual item is created by caling VisualItemCreating event. But how can I trigger the event?

As I understand the function SynchronizeProperties() is used to assign values to visualElements when the custom visual items are created (please let me know if I am wrong). In the example code, the value assigned to custom visual item are from data table. But In my case I want to assign the value of properties of a object from the object list to each custom visual item. What steps I need to go through to achieve that?

Thanks a lot

2 Answers, 1 is accepted

Sort by
0
Alvin
Top achievements
Rank 1
answered on 06 Dec 2011, 01:28 AM
I seem to find out how this work.

Thanks
0
Ivan Todorov
Telerik team
answered on 06 Dec 2011, 04:03 PM
Hi Alvin,

I am glad that you have managed to sort this out.

Nevertheless, here is a brief info which might help others as well:

RadListView uses a virtualization mechanism to display its items. This means that it can contain thousands of logical items while only using a few visual items (as much as are needed to cover the client area of the control). Visual items are stored in a cache and are reused for displaying logical items. When the visual items are not sufficient for covering the client area (at the beginning they are 0), new visual items are created and the VisualItemCreating event is fired. When a logical item is being attached to a visual item, the Attach method of the visual item is called. SynchronizeProperties is called both on Attach and when the logical item changes some of its properties (this reflects changes in the logical item directly to the visual one, if such exists). In addition, every visual item has a IsCompatible method which should indicate whether this visual item is compatible with the given logical item. If there isn't any compatible item in the cache, a new visual item is created and the VisualItemCreating is fired again.

I hope you find this helpful. If you have any further questions on this, do not hesitate to ask.

Best wishes,
Ivan Todorov
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

Tags
ListView
Asked by
Alvin
Top achievements
Rank 1
Answers by
Alvin
Top achievements
Rank 1
Ivan Todorov
Telerik team
Share this question
or