Back to Devexpress

BaseListBoxControl.HtmlImages Property

windowsforms-devexpress-dot-xtraeditors-dot-baselistboxcontrol-e522dfbd.md

latest3.8 KB
Original Source

BaseListBoxControl.HtmlImages Property

Gets or sets a collection of images that can be inserted into item captions using the image tag.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DefaultValue(null)]
[DXCategory("Appearance")]
public object HtmlImages { get; set; }
vb
<DefaultValue(Nothing)>
<DXCategory("Appearance")>
Public Property HtmlImages As Object

Property Value

TypeDefaultDescription
Objectnull

An image collection (DevExpress.Utils.ImageCollection or DevExpress.Utils.SvgImageCollection).

|

Remarks

Enable the BaseListBoxControl.AllowHtmlDraw property to use a set of HTML-inspired tags to format the display text of the control’s items.

When you compose an HTML string, you can use the image tag to insert an image from an image collection and project’s resources into the text.

To insert an image from an image collection, do the following:

  • Create an image collection (ImageCollection or SvgImageCollection) and populate it with images.
  • Assign the collection to the HtmlImages property.
  • When you use the image tag, address a target image by its name (image names can be obtained from the image collection).

See HTML Text Formatting to learn more.

Example

The following code shows how to create items for a ListBoxControl and format the items’ display text using HTML tags. The image HTML tag is used to insert an image into an item’s text from an ImageCollection, assigned to the BaseListBoxControl.HtmlImages property. The HTML formatting feature is activated via the BaseListBoxControl.AllowHtmlDraw feature.

csharp
listBoxControl1.ItemHeight = 20;
listBoxControl1.HtmlImages = imageCollection1;
listBoxControl1.AllowHtmlDraw = DefaultBoolean.True;
for (int i = 0; i < imageCollection1.Images.Count; i++) {
    string item = String.Format("id: {0} - <image={1}>", i, imageCollection1.Images.InnerImages[i].Name);
    listBoxControl1.Items.Add(item);
}
vb
listBoxControl1.ItemHeight = 20
listBoxControl1.HtmlImages = imageCollection1
listBoxControl1.AllowHtmlDraw = DefaultBoolean.True
Dim i As Integer = 0
Do While i < imageCollection1.Images.Count
    Dim item As String = String.Format("id: {0} - <image={1}>", i, imageCollection1.Images.InnerImages(i).Name)
    listBoxControl1.Items.Add(item)
    i += 1
Loop

See Also

AllowHtmlDraw

HTML-inspired Text Formatting

BaseListBoxControl Class

BaseListBoxControl Members

DevExpress.XtraEditors Namespace