windowsforms-404113-controls-and-libraries-editors-and-simple-controls-examples-how-to-display-svg-icons-within-look-up-dropdown.md
This example demonstrates how to display SVG icons from the SvgImageCollection within the LookUp editor’s dropdown.
using System;
using System.Collections.Generic;
using DevExpress.Utils;
using DevExpress.Utils.Svg;
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
lookUpEdit1.Properties.AllowNullInput = DefaultBoolean.True;
lookUpEdit1.Properties.DataSource = InitData();
lookUpEdit1.Properties.ValueMember = "ID";
lookUpEdit1.Properties.DisplayMember = "DocumentFormat";
}
List<DataObject> InitData() {
return new List<DataObject>() {
new DataObject(0, "MS Word Binary File Format") { SvgImage = svgImageCollection1[0] },
new DataObject(1, "Portable Document Format") { SvgImage = svgImageCollection1[1] },
new DataObject(2, "Microsoft Excel Spreadsheet") { SvgImage = svgImageCollection1[2] },
new DataObject(3, "Extensible Markup Language") { SvgImage = svgImageCollection1[3] }
};
}
}
public class DataObject {
int fId;
public DataObject(int fId, string format) {
this.fId = fId;
DocumentFormat = format;
}
public int ID {
get { return fId; }
}
public SvgImage SvgImage { get; set; }
public string DocumentFormat { get; set; }
}
Imports System
Imports System.Collections.Generic
Imports DevExpress.Utils
Imports DevExpress.Utils.Svg
Partial Public Class Form1
Inherits DevExpress.XtraEditors.XtraForm
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
lookUpEdit1.Properties.AllowNullInput = DefaultBoolean.True
lookUpEdit1.Properties.DataSource = InitData()
lookUpEdit1.Properties.ValueMember = "ID"
lookUpEdit1.Properties.DisplayMember = "DocumentFormat"
End Sub
Private Function InitData() As List(Of DataObject)
Return New List(Of DataObject)() From {
New DataObject(0, "MS Word Binary File Format") With {.SvgImage = svgImageCollection1(0)},
New DataObject(1, "Portable Document Format") With {.SvgImage = svgImageCollection1(1)},
New DataObject(2, "Microsoft Excel Spreadsheet") With {.SvgImage = svgImageCollection1(2)},
New DataObject(3, "Extensible Markup Language") With {.SvgImage = svgImageCollection1(3)}
}
End Function
End Class
Public Class DataObject
Private fId As Integer
Public Sub New(ByVal fId As Integer, ByVal format As String)
Me.fId = fId
DocumentFormat = format
End Sub
Public ReadOnly Property ID() As Integer
Get
Return fId
End Get
End Property
Public Property SvgImage() As SvgImage
Public Property DocumentFormat() As String
End Class