Can I disable an item in a dropdownlist in 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
Yes you can.
ListItem
s in your dropdownlist have an Enabled property. You can set this to false
to disable them.
EDIT:
Sorry I made the assumption you were using WebForms (ASP.Net). For windows forms, you can take a look at this answer: Create WinForms ComboBox with non-selectable items - its the same principle but with some slight implementation details because Combobox Items
collection is one of objects. Dropdownlist
(the Web form equivalent) uses typed 'ListItem' objects.
HTH.