在运行时将项目添加到列表视图 [英] adding items to listview at runtime

查看:149
本文介绍了在运行时将项目添加到列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用添加新值到ListView:

When I add new values to a listview using :

    Set lstView = ListView(0).ListItems.Add(, , txtName)
    lstView.ListSubItems.Add , , txtValue
    lstView.Refresh

唯一的问题是,这只是显示在ListView空白的新线,任何想法如何正确地更新它?

The only problem is that this only displays a blank new line in the listview, any idea how to update it correctly?

通常情况下,我使用的记录如此简单清楚,然后重新填充数据,但我需要的用户能够将条目添加到列表视图。我会再通过列表视图循环增加值TOT他DB只有当用户完成修改列表视图。

Normally I am using a recordset so simply clear then repopulate the data but I need the user to be able to add entries to the listview. I will then cycle through the listview adding the values tot he DB only once the user has finished amending the listview.

感谢您事先的任何帮助。

Thanks in advance for any help.

推荐答案

假设你的ListView的.View属性设置为报告,下面就一对夫妇行添加到控制和设置子项的文字。

Assuming the .View property of your ListView is set to "Report", the following will add a couple of rows to the control and set the sub item text.

Dim li As ListItem

With ListView1
    .ColumnHeaders.Add , , "One"
    .ColumnHeaders.Add , , "Two"
    .ColumnHeaders.Add , , "Three"

    Set li = .ListItems.Add(, , "Row1Item1")
    li.SubItems(1) = "Row1Item2"
    li.SubItems(2) = "Row1Item3"

    Set li = .ListItems.Add(, , "Row2Item1")
    li.SubItems(1) = "Row2Item2"
    li.SubItems(2) = "Row2Item3"
End With

这篇关于在运行时将项目添加到列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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