如何更新listviewitems? [英] How to update listviewitems?

查看:83
本文介绍了如何更新listviewitems?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表视图,包含Dealer,RecievedDate,ResolvedDate,Aging和Status(活动和关闭)列。我需要更新仍然处于活动状态的所有行,其中Aging是当前日期与RecievedDate的每次加载形式的差异。

解决方案

stebo0728给出了你是个好主意。从您的问题来看,您似乎想要使用 View = System.Windows.Forms.View.Details

在很多情况下,你使用 System.Windows.Forms.DataGridView 可以获得更好的结果: https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview%28v=vs.110%29.aspx [ ^ ]。



您无需更新视图;修改数据时会更新,在这种情况下, System.Windows.Forms.DataGridViewCell.Value 属性:

https://msdn.microsoft.com/en-us/library /system.windows.forms.datagridviewcell.value(v=vs.110).aspx [ ^ ],

https://msdn.microsoft.com/en-us/library/system。 windows.forms.datagridviewcell.valuetype(v = vs.110).aspx [ ^ ]。



同样如此 System.Windows.Forms.ListView 。修改 ListViewItem ListViewItem.ListViewSubItem 时,视图会发生变化。请仔细阅读文档,包括代码示例,然后尝试一下:

https://msdn.microsoft.com/en-us/library/system.windows.forms.listview%28v=vs.110%29.aspx [ ^ ],

https://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem(v = vs.110).aspx [ ^ ] ,

https://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.listviewsubitem(v= vs.110).aspx [ ^ ]。



如果您使用的是数据库,首先请考虑使用< I>结合的。请参阅:

https:// msdn .microsoft.com / zh-CN / library / ef2xyb33%28v = vs.90%29.aspx [ ^ ],

详细的数据绑定教程 [ ^ ],

.NET窗体中的数据绑定概念 [ ^ ]。



-SA

I have a listview with the columns Dealer, RecievedDate, ResolvedDate, Aging and Status(active and closed). I need to update all the rows that are still Active, where the Aging is the difference of the Current date and the RecievedDate every load of the form.

解决方案

stebo0728 gave you a pretty good idea. From your question, it looks like you want to use the View = System.Windows.Forms.View.Details.
In many cases, you can get much better results using System.Windows.Forms.DataGridView: https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview%28v=vs.110%29.aspx[^].

You don't need to update the view; it is updated when you modify data, in this case, System.Windows.Forms.DataGridViewCell.Value property:
https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.value(v=vs.110).aspx[^],
https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.valuetype(v=vs.110).aspx[^].

Same thing goes with System.Windows.Forms.ListView. The view is changes when you modify ListViewItem or ListViewItem.ListViewSubItem. Please read the documentation carefully, including the code sample, and try it out:
https://msdn.microsoft.com/en-us/library/system.windows.forms.listview%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem(v=vs.110).aspx[^],
https://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.listviewsubitem(v=vs.110).aspx[^].

If you are using the database, first of all, consider using binding. Please see:
https://msdn.microsoft.com/en-us/library/ef2xyb33%28v=vs.90%29.aspx[^],
A Detailed Data Binding Tutorial[^],
Data binding concepts in .NET windows forms[^].

—SA


这篇关于如何更新listviewitems?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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