Jonas Gobel
Jonas Gobel

Reputation: 153

How to disable click in Listbox c#/.net

I have added many items in my listbox and I am using selected items of listbox using this code:

  listBox1.SelectedIndex = listBox1.SelectedIndex + 1;

I also want to disable click in listbox. Please tell me how can I disable click in listbox when program is running.

Upvotes: 1

Views: 3324

Answers (1)

CodeCaster
CodeCaster

Reputation: 151604

Simply set the Enabled property to false to disable user interaction.

However, this sounds as if you're (ab)using the GUI to implement application logic. Shouldn't you use a List<something> to store and iterate through your items and update your ListBox from the List<> instead of depending on what's on screen?

Upvotes: 2

Related Questions