我想创建一个 ListBox
控件,允许用户编辑项目,就像 Launchy 中的扩展列表框一样。在 WinForms 中是否可行?我尝试使用 Autoit Window Info 查看该列表框,其显示为 QWidget(可能与 Qt 相关)。
尝试使用ListView
控件。
将其LabelEdit
属性设置为True,以允许用户编辑项目名称。
要允许用户编辑新插入的项上的文本,您可以使用以下代码:
private void AddItemToListView()
{
// Add a new item to the ListView, with an empty label
// (you can set any default properties that you want to here)
ListViewItem item = listView1.Items.Add(String.Empty);
// Place the newly-added item into edit mode immediately
item.BeginEdit();
}