我想重命名列表框中选定的项目。
我怎样才能做到这一点?
谢谢。
编辑:几年后重新审视这个问题;以下是根据您使用的 UI 框架执行此操作的方法。这假设您想要更改所选文本。
ASP.Net Web 表单
protected void ChangeListBoxSelectedItemText(string textToChangeTo)
{
lstBoxExample.SelectedItem.Text = textToChangeTo;
}
WPF - 假设 ListBox 包含 Label 对象
// To achieve this in WPF you have to cast the object
// This is because a ListBox can contain numerous types of UI objects
var selectedLabel = (Label)lstBoxExample.SelectedItem;
selectedLabel.Content = "Text to change to";
WinForms
// There may very well be a better way to do this
lstBoxExample.Items[lstBoxExample.SelectedIndex] = "New Item";
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)