Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6660661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:10:58+00:00 2026-05-26T02:10:58+00:00

I have a CListCtrl (report style) where I clear the list and repopulate it

  • 0

I have a CListCtrl (report style) where I clear the list and repopulate it at certain times. I’d like to maintain the vertical scroll position when doing this. I see there are a couple methods that look promising:

EnsureVisible()
GetScrollPos()
SetScrollPos()
GetScrollInfo()
GetTopIndex()
Scroll()

I’m trying GetScrollPos() and then SetScrollPos() but it doesn’t appear to be working. What is the simple correct way to save a scroll position and then later restore it?

UPDATE

Actually it seems I can get to save the scroll position GetScrollPos() and then SetScrollPos() to restore it, however it literally just seems to set the scroll bar position and does not actually scroll the items of my CListCtrl.

UPDATE 2

The Scroll() method seems to correctly scroll the scrollbars and the contents. However it takes a CSize object as it’s argument. So the question would be how to translate between the CSize and the output of either GetTopIndex or GetScrollInfo/Pos.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:10:59+00:00Added an answer on May 26, 2026 at 2:10 am

    I’ve done that in the past. IIRC, the trick consisted in:

    int topIndex= m_List.GetTopIndex();
    RenewContents();
    m_List.EnsureVisible(m_List.GetItemCount() - 1); // Scroll down to the bottom
    m_List.EnsureVisible(topIndex);// scroll back up just enough to show said item on top
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have CListCtrl.EditLabel() for any column of the list. How can I
I have an owner-drawn list control in my Windows program. I use CListCtrl::GetBkColor to
I have a class which inherits from CListCtrl class, say class list. I have
How to implement CEditListCtrl?. List control with edit capabality (Report/Grid view). I have a
I have a CListCtrl with plenty of room for all of the items, and
I have a CListCtrl control that has 2 columns and any number of rows.
in my application I have a few CListCtrl tables. I fill/refresh them with data
I have a ListCtrl that displays a list of items for the user to
I have a list of items that are each associated with a start and
**Have it working now. I forgot to populate the Array List. How embarrassing. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.