Hello Alexander,
I completely agree with you that the null text should be shown whenever there is no item selected in a
DropDownList, but until they will fix this, i would suggest you try this workaround:
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
using
Telerik.WinControls.UI;
namespace
TestDropDownListNullText
{
public
partial
class
Form1 : Form
{
public
RadDropDownList radDropDownList1;
public
Form1()
{
InitializeComponent();
this
.Load +=
new
EventHandler(Form1_Load);
}
void
Form1_Load(
object
sender, EventArgs e)
{
radDropDownList1 =
new
RadDropDownList();
radDropDownList1.Dock = DockStyle.Top;
this
.Controls.Add(radDropDownList1);
radDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
radDropDownList1.PopupClosing +=
new
RadPopupClosingEventHandler(radDropDownList1_PopupClosing);
radDropDownList1.DataSource =
new
TestsCollection(10);
radDropDownList1.DisplayMember =
"Name"
;
radDropDownList1.Text =
"Please select something..."
;
}
void
radDropDownList1_PopupClosing(
object
sender, RadPopupClosingEventArgs args)
{
if
(
string
.IsNullOrEmpty(radDropDownList1.Text))
{
radDropDownList1.Text =
"Please select something..."
;
}
}
}
#region Business Objects
public
class
Test
{
public
int
Id
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
Test(
int
id,
string
name)
{
this
.Id = id;
this
.Name = name;
}
}
public
class
TestsCollection : List<Test>
{
public
TestsCollection(
int
noItems)
{
for
(
int
i = 0; i < noItems; i++)
{
this
.Add(
new
Test(i,
"test"
+ i));
}
}
}
#endregion Business Objects
}
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga