Print Page | Close Window

Remembering scroll position in PropertyGrid

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Property Grid
Forum Description: Topics Related to Codejock Property Grid
URL: http://forum.codejock.com/forum_posts.asp?TID=19688
Printed Date: 13 May 2024 at 9:50am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Remembering scroll position in PropertyGrid
Posted By: ericchubb
Subject: Remembering scroll position in PropertyGrid
Date 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




Replies:
Posted By: mgampi
Date 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 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017


Posted By: ericchubb
Date 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


Posted By: mgampi
Date 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 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net