Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Property Grid
  New Posts New Posts RSS Feed - Remembering scroll position in PropertyGrid
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Remembering scroll position in PropertyGrid

 Post Reply Post Reply
Author
Message
ericchubb View Drop Down
Groupie
Groupie


Joined: 31 May 2010
Location: Ireland
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote ericchubb Quote  Post ReplyReply Direct Link To This Post Topic: Remembering scroll position in PropertyGrid
    Posted: 24 April 2012 at 9:03am
Hi there

I have a CXTPPropertyGrid which I empty and repopulate each time a user clicks between items on a CXTPReportControl. When the repopulation is complete, the scrollbar and scroll position of the PropertyGrid always reset back to the top, which can be frustrating for users if they are viewing fields at the bottom of the scroll view, so I'd like to be able to store the current scroll state of the property grid prior to updating, and reapply it after the control has been repopulated. The property grid will always contain the same number and type of fields so it is safe to re-use the scroll position, but I'm just not sure how to do it.

What I have tried so far is:

SCROLLINFO si;
CXTPPropertyGridView & vView = pPropertyGrid->GetGridView();
vView.GetScrollInfo(SB_LINEDOWN, &si);     
int nOldPos = si.nPos;
//Do repopulation stuff
if (si.nPos != nOldPos)
{                    
     vView.ScrollWindow ((nOldPos - si.nPos),0);
}

But this doesn't seem to work. I've also tried 
vView.SetScrollInfo(SB_LINEDOWN, &scrollinfo);         
and
vView.SetScrollPos(SB_LINEDOWN,scrollinfo.nPos);
but they didn't work either, so I'm stuck as to what to try next. 
Any help would me much appreciated
Eric

Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 24 April 2012 at 6:10pm
Hi;

Have you ever tried using CXTPPropertyGrid::GetTopIndex(), CXTPPropertyGrid::SetTopIndex() to position to the previous visible region? But you also have to save/restore the expand/collapse state of each item in the control.
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022
Back to Top
ericchubb View Drop Down
Groupie
Groupie


Joined: 31 May 2010
Location: Ireland
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote ericchubb Quote  Post ReplyReply Direct Link To This Post Posted: 25 April 2012 at 11:42am
Hi Martin,

Thanks for your reply. I tried GetTopIndex but it returns 0 every time regardless of the scroll position of the the grid. I also tried invoking GetTopIndex on the property grid's view member object but again , no difference.

Eric
Eric



Product: Xtreme Toolkit Version 22.0

Platform: Windows 11 (64bit) -

Language: Visual C++ 2022 /C# .NET 2/3.5/4/5/6/7
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 26 April 2012 at 4:49am
Hi;

This sounds like a bug!
Perhaps you should open a support ticket.
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.