C#:如何编辑列表视图中的项目和子项目? [英] C#: How do you edit items and subitems in a listview?

查看:27
本文介绍了C#:如何编辑列表视图中的项目和子项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编辑列表视图中的项目和子项目?假设我有一个包含 3 列和子项的列表视图,

How do you edit items and subitems in a listview? Let's say I have a listview with 3 columns,and subitems,

汽车品牌 |车名 |车年福特 |野马 |2000年道奇|充电器|2007年

Car Brand | Car Name | Car Year
Ford      | Mustang  | 2000
Dodge     | Charger  | 2007

如果我需要在运行时在触发事件时进行编辑,我将如何将这样的项目添加到列表视图中,以及我将如何编辑让我们通过索引 [] 说出哪一行的汽车名称?

How would I Add items like that to listview and how would I edit let's say the Car Name on which ever row by index[] if I needed to edit at runtime at firing of an event?

推荐答案

如果您正在寻找就地"编辑 ListView 的内容(特别是详细信息视图模式),您需要自己实现,或使用第三方控件.

If you're looking for "in-place" editing of a ListView's contents (specifically the subitems of a ListView in details view mode), you'll need to implement this yourself, or use a third-party control.

默认情况下,使用标准"ListView 可以实现的最佳效果是将其 LabelEdit 属性设置为 true 以允许用户编辑第一个的文本ListView 的列(假设您希望允许自由格式的文本编辑).

By default, the best you can achieve with a "standard" ListView is to set it's LabelEdit property to true to allow the user to edit the text of the first column of the ListView (assuming you want to allow a free-format text edit).

允许就地"编辑子项的自定义 ListView 的一些示例(包括完整的源代码)是:

Some examples (including full source-code) of customized ListView's that allow "in-place" editing of sub-items are:

C# 可编辑列表视图
就地编辑 ListView 子项

这篇关于C#:如何编辑列表视图中的项目和子项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆