具有动态列的列表视图
我有一个具有 LVS_REPORT
样式的列表视图,并且我使用 LVS_EX_HEADERDRAGDROP
样式来允许用户移动列。 用户将能够动态添加/删除列。我将其填充到 LVN_GETDISPINFO
中。
因此,除非我看错了,否则我需要跟踪哪些列是可见的,以及它们的顺序。
我当前的实现是为每列提供一个“列 id”的枚举和一个整数数组,数组中的值将指定列位置。
示例:
enum {FIRSTNAME = 0, LASTNAME, STREET, ADDRESS};
int cols[] = {
LASTNAME, // Last Name, this will be displayed in the first column
FIRSTNAME, // First Name, this will be displayed in the second column
ADDRESS // Address, this is displayed in the third column
};
在 LVN_GETDISPINFO
中:
NMLVDISPINFO *plvdi = reinterpret_cast<NMLVDISPINFO*>(lParam);
if (cols[plvdi->item.iSubItem] != -1)
{
GetDataByRowAndColumn(plvdi->item.iItem, cols[plvdi->item.iSubItem]);
}
现在的问题是,如果用户更改列的顺序,我还没有找到一种方法来找出列的新顺序,以便我可以更新我的数组。
那么当用户更改列的顺序时是否会发送消息? 我在msdn上没找到。 或者我这样做的方法完全错误,我应该以不同的方式处理这个问题?
I have a List-View with LVS_REPORT
style, and i'm using the LVS_EX_HEADERDRAGDROP
style to allow the user to move the columns around.
And the user is going to be able to add/remove columns dynamically. And i'm populating it in LVN_GETDISPINFO
.
So unless i'm looking at this all wrong, I need to keep track of which columns are visible, and in what order they are.
My current implementation is to have an enum
of 'column ids' and an array of ints
for each column, and the value in the array will specify the column position.
Example:
enum {FIRSTNAME = 0, LASTNAME, STREET, ADDRESS};
int cols[] = {
LASTNAME, // Last Name, this will be displayed in the first column
FIRSTNAME, // First Name, this will be displayed in the second column
ADDRESS // Address, this is displayed in the third column
};
And in LVN_GETDISPINFO
:
NMLVDISPINFO *plvdi = reinterpret_cast<NMLVDISPINFO*>(lParam);
if (cols[plvdi->item.iSubItem] != -1)
{
GetDataByRowAndColumn(plvdi->item.iItem, cols[plvdi->item.iSubItem]);
}
Now the problem is, if a user changes the order of the columns, I haven't found a way to figure out the new order of the columns so I can update my array.
So is there a message sent when the user changes the order of the columns?
I haven't found one on msdn.
Or is my method of doing this completely wrong, and I should approach this differently?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论