This example shows how to create and use a TextEdit descendant that will display an image from an ImageCollection and provide the capability of runtime image selection.
This descendant's repository items have two additional properties:
RepositoryItems.ImageList - get or set an images source.
RepositoryItems.ImageIndex - get or set an index of the image that should be displayed.
And two additional events
RepositoryItems.IconClick - occurs when a user clicks on an image.
RepositoryItems.OnIconSelection - this event can be used to specify the index of the image that should be displayed. The event handler receives an argument of the OnIconSelectionEventArgs type for providing data related to this event.
The OnIconSelectionEventArgs has two properties.
ImageList - gets an image source specified in the RepositoryItems.ImageList property.
ImageIndex - gets or sets the index of the image that should be displayed.
You should assign the index of the image that you want to display to the OnIconSelectionEventArgs.ImageIndex property.
In the attached example the ImageCollection control is used for storing images. It is assigned to the RepositoryItems.ImageList properties of the created controls. The RepositoryItems.OnIconSelection event is used for the image selection according to the editor state. The RepositoryItems.IconClick event assigns the Form.Text property.
See Also:
How to force a TextEdit to display an image against the text