I want to rename selected item in listbox. How to I can do this? Thanks.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
ListBox
contains objects. Exactly what do you mean by "renaming" an item?If what you want is to change the text that is displayed on the list, what you have to do is change the object so that its
ToString
method will return the desired text.Most commonly, you are probably storing strings in the
ListBox
, and in that case in order to "rename" an item, you have to remove the old item and insert the new text in the same index.Edit: Revisiting this quite a few years later; below are the ways you can do this dependent on the UI framework you are using. This carries the assumption that you'd like to change the selected text.
ASP.Net WebForms
WPF - Assuming the ListBox contains Label objects
WinForms