自已维护每条记录 用户选择后更新一下 如定义 struct Info{ int index; CString name; ... } Info m_info[100000];int m_icount记录总的记录数 int m_iselectitem;选取的条目初始为0 写一个函数 UpdateList(int item)//显示第item条到m_icount的内容 {}
SetItemPosition在列表视图控件中移动一项到指定位置msdnCListCtrl::SetItemPosition BOOL SetItemPosition( int nItem, POINT pt );Return ValueNonzero if successful; otherwise zero.ParametersnItemIndex of the item whose position is to be set.ptAPOINT structure specifying the new position, in view coordinates, of the item’s upper-left corner.ResMoves an item to a specified position in a list view control. The control must be in icon or small icon view.If the list view control has the LVS_AUTOARRANGE style, the list view is arranged after the position of the item is set.
GetViewRect得到点的位置 然后再用SetItemPosition
int n= GetCountPerPage();//得到当前页能显示多少行 if (nItem+n<=GetItemCount()) { EnsureVisible( nItem+n); } else { EnsureVisible( nItem);//当此记录为最后几条时不能显示到第一条, //除非你添加几条空的记录保证当前页能满 }
用户选择后更新一下
如定义
struct Info{
int index;
CString name;
...
}
Info m_info[100000];int m_icount记录总的记录数
int m_iselectitem;选取的条目初始为0
写一个函数
UpdateList(int item)//显示第item条到m_icount的内容
{}
BOOL SetItemPosition( int nItem, POINT pt );Return ValueNonzero if successful; otherwise zero.ParametersnItemIndex of the item whose position is to be set.ptAPOINT structure specifying the new position, in view coordinates, of the item’s upper-left corner.ResMoves an item to a specified position in a list view control. The control must be in icon or small icon view.If the list view control has the LVS_AUTOARRANGE style, the list view is arranged after the position of the item is set.
然后再用SetItemPosition
if (nItem+n<=GetItemCount())
{
EnsureVisible( nItem+n);
}
else
{
EnsureVisible( nItem);//当此记录为最后几条时不能显示到第一条,
//除非你添加几条空的记录保证当前页能满
}
punkboy(朋克小子) 你接到分了吗?我全给你了。多谢你了!!!