Hello again,
Sorry there is no very easy way of doing this but you can register for the
ItemDataBound event and set the image there, like this example:
using
System;
using
System.ComponentModel;
using
System.Drawing;
using
System.Windows.Forms;
using
Telerik.WinControls.UI;
public
partial
class
Form1 : Form
{
private
RadDropDownList radDropDownList1;
public
Form1()
{
InitializeComponent();
this
.Controls.Add(radDropDownList1 =
new
RadDropDownList());
radDropDownList1.ItemDataBound +=
new
ListItemDataBoundEventHandler(radDropDownList1_ItemDataBound);
radDropDownList1.Dock = DockStyle.Top;
}
protected
override
void
OnLoad(EventArgs e)
{
base
.OnLoad(e);
radDropDownList1.DataSource =
new
TestsCollection();
radDropDownList1.DisplayMember =
"Name"
;
radDropDownList1.ValueMember =
"Id"
;
}
void
radDropDownList1_ItemDataBound(
object
sender, ListItemDataBoundEventArgs args)
{
var test = args.NewItem.DataBoundItem
as
Test;
if
(test ==
null
)
{
return
;
}
args.NewItem.Image = test.Image;
}
}
public
class
Test
{
public
int
Id
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
Image Image
{
get
;
set
;
}
public
Test(
int
id,
string
name, Image image)
{
this
.Id = id;
this
.Name = name;
this
.Image = image;
}
}
public
class
TestsCollection : BindingList<Test>
{
public
TestsCollection()
{
this
.Add(
new
Test(1,
"Test1"
, Properties.Resources.ar));
this
.Add(
new
Test(2,
"Test2"
, Properties.Resources.ca));
}
}
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP