English 中文(简体)
是否可以禁用c#中下拉列表组合框中的项目?
原标题:Is it possible to disable an item in a dropdownlist combobox in c#?

我可以禁用c#中的下拉列表中的项目吗?

For example, I have 2 dropdownlist combobox. Both of them consist of months (jan, feb, mar, apr, etc....) and both of them will function like a range of month in a certain year. When I choose apr on the 1st combobox, the second combobox can t choose jan, feb, mar

问题回答

是的,你可以。

您的下拉列表中的ListItem具有已启用属性。您可以将其设置为false以禁用它们。

编辑:

很抱歉,我假设您使用的是WebForms(ASP.Net)。对于windows表单,您可以查看以下答案:使用不可选择的项创建WinForms组合框-原理相同,但有一些轻微的实现细节,因为组合框items集合是对象之一。Dropdownlist(等效的Web表单)使用类型化的ListItem对象。

高。





相关问题
WPF Datagrid, Setting the background of combox popup

I would like to change the color of the popup background when using a DatagridComboboxColumn in the WPF Toolkit datagrid. I ve edited the Template for a normal Combobox and it works great for selected ...

How to insert ComboBox item into ListBox? [winforms]

The question is very simple, How to insert ComboBox selected item into ListBox using c#? I have tried with this: listbox.Items.Add(combobox.SelectedItem); and some other permutations but it always ...

How do I bind a ComboBox to a one column list

I ve seen how to bind a ComboBox to a list that has columns like this: ItemsSource="{Binding Path=Entries}" DisplayMemberPath="Name" SelectedValuePath="Name" SelectedValue="{Binding Path=Entry}" But ...

Wpf Combobox Limit to List

We are using Wpf Combobox to allow the user to do the following things: 1) select items by typing in the first few characters 2) auto complete the entry by filtering the list 3) suggesting the first ...

热门标签