如何动态更新ListView? [英] How do I dynamically update a ListView?
问题描述
大家好,
我想在定时事件中将数据插入Listview,而不是通过按钮点击。这意味着在整个软件运行时,将不断添加和删除行。
如何进行此操作?我可以在创建ListView时添加行,例如
Hello All,
I'm looking to insert data into a Listview on a timed event rather than through a button click. This means that throughout the runtime of the software, rows will be continually added and deleted.
How do I go about doing this? I can add rows when I create the ListView e.g.
LVITEM lvi;
lvi.mask = LVIF_TEXT;
lvi.iItem = 0;
lvi.iSubItem = 0;
lvi.pszText = bob;
ListView_InsertItem(list, &lvi);
但我不知道哪个windows消息处理程序如果我想在飞行中更新,我需要把它放进去。例如。它会进入WM_PAINT吗? WM_NOTIFY?等等。
我在没有MFC的情况下使用Win32 listview。
提前致谢!
But I don't know which windows message handler I would need to put this in if I wanted to update on-the-fly. E.g. does it go in WM_PAINT? WM_NOTIFY? Etc.
I'm using the Win32 listview without MFC.
Thanks in advance!
推荐答案
您可以在应用程序中的任何位置修改列表视图你知道HWND
。所以在某处存储HWND
并在你的计时器函数中使用它。
You can modify the list view from any point within your application when you know theHWND
. So store theHWND
somewhere and use it from within your timer function.
这篇关于如何动态更新ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!