WinForms ListBox with readonly/disabled items

后端 未结 5 1643
傲寒
傲寒 2021-01-18 20:39

Is there a way to make some of the items in a ListBox readonly/disabled so they can\'t be selected? Or are there any similar controls to ListBox to provide this functionalit

5条回答
  •  情书的邮戳
    2021-01-18 21:25

    I know this is old thread, but i'll post a workaround for other readers in future.

    listBox.Enabled = false;
    listBox.BackColor = Color.LightGray;
    

    This will change background color of list box to Light Gray. So this is not builtin "native way" to do it, but at least gives user some feedback that he is not supposed to / can't edit that field.

提交回复
热议问题