How do I make a ListBox refresh its item text?

前端 未结 10 1983
后悔当初
后悔当初 2020-12-03 04:42

I\'m making an example for someone who hasn\'t yet realized that controls like ListBox don\'t have to contain strings; he had been storing formatted strings and

10条回答
  •  爱一瞬间的悲伤
    2020-12-03 04:57

    I use this class when I need to have a list box that updates.

    Update the object in the list and then call either of the included methods, depending on if you have the index available or not. If you are updating an object that is contained in the list, but you don't have the index, you will have to call RefreshItems and update all of the items.

    public class RefreshingListBox : ListBox
    {
        public new void RefreshItem(int index)
        {
            base.RefreshItem(index);
        }
    
        public new void RefreshItems()
        {
            base.RefreshItems();
        }
    }
    

提交回复
热议问题