如何在WPF中重命名listview中的项目 [英] How do I rename an item in listview in WPF

查看:77
本文介绍了如何在WPF中重命名listview中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我需要通过在运行时在列表视图中对其进行编辑来重命名listview中的项目,并且数据库中的更改应该受到影响。 br />


我在winforms中使用listview.FocusedItem.BeginEdit()做了同样的事情,但在WPF中,我无法获得FocusedItem,所以我被困在这里。



提前致谢。



问候,

RV

解决方案

以下代码是否有效?

  / /  获取项目 
var item = listView.SelectedItem as ListViewItem;

// 更新文本
item.Text = < span class =code-string> 新文字;



WPF是<我>别的什么。它通常基于不同的组件,例如它使用DirectX等的图形,因此API也必须是不同的。我建议您阅读这些项目的MSDN文档。您可以选择其他项目,我只是粗略猜测您要编辑 SelectedItem 的文本,这是用户点击时所做的选择项目。您可能希望在事件上编辑鼠标,然后检查鼠标光标下当前的项目。



ListView类(System.Windows.Controls) [ ^ ]

ListViewItem类(System.Windows.Controls) [ ^ ]

选择器。 SelectedItem属性(System.Windows.Controls.Primitives) [ ^ ]


Hi all,

I need to rename an item in listview by editing it in the list view on run time and the changes should be affected in database.

I have done the same in winforms by using listview.FocusedItem.BeginEdit(), but in WPF, I can't get the FocusedItem, so I am stuck up here.

Thanks in advance.

Regards,
RV

解决方案

Doesn't the following code work?

// Get the item
var item = listView.SelectedItem as ListViewItem;

// Update its text
item.Text = "New text";


WPF is something else. It is usually based on different components, like for graphics it uses DirectX and so on, so the API also had to be different. I would recommend that you read MSDN documentation for these items. You can select other items, I just made a rough guess that you want to edit the text of the "SelectedItem", this is the choice that is made when user clicks on an item. You may want to edit the mouse over events and then check which item is currently under the mouse cursor.

ListView Class (System.Windows.Controls)[^]
ListViewItem Class (System.Windows.Controls)[^]
Selector.SelectedItem Property (System.Windows.Controls.Primitives)[^]


这篇关于如何在WPF中重命名listview中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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