Tech Learner
Tech Learner

Reputation: 1317

Disable selection from Radcombobox list of values

I want to list all the items in the radcombobox (Values are binded from dataset) but user should not be allowed to select any value from radcombobox.

User should able to see all the items but selecting an item should be disabled.

I would appreciate any help. Thanks in advance.

Upvotes: 2

Views: 4034

Answers (2)

novice_dev
novice_dev

Reputation: 714

Assign the data to the RadComboBox.DataSource. Then disable the combobox. "Name" and "Value" must be a part of your dataset returned from the stored proc.

In this example, I am using a EntityFramework lambda expression to get list of Users.

The table has 3 column - UserId, Name, Salary

combo.DataSource = dbCtx.tbl_users.Where(u => u.salary > 1000).OrderBy(u => u.user_id).ToList();
combo.DataTextField = "Name"
combo.DataValueField = "UserId";
combo.Enabled = false;

Upvotes: 0

user5459023
user5459023

Reputation:

You can do it in aspx part of the page. Right in this way.

<telerik:RadComboBox x:Name="radComboBox" Width="200">
        <telerik:RadComboBoxItem Content="Alapattah" IsEnabled="False"/>
        <telerik:RadComboBoxItem Content="Brickell Avenue" />
        <telerik:RadComboBoxItem Content="Downtown Miami" IsEnabled="False"/>
    </telerik:RadComboBox>

But if you are binding it programatically, you can do something like this:

foreach(RadComboBoxItem item in radComboBox.Items)
{
    item.Enabled = false;
}

Then in both cases user can view, but can't select disabled items.

More info is here: http://docs.telerik.com/devtools/wpf/controls/radcombobox/howto/enable-disable-radcombobox-items

Upvotes: 4

Related Questions