Ensure a row is visible in wxProprtyGrid Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Ensure a row is visible in wxProprtyGrid

Post by Widgets »

Is there a way to ensure that an adjacent row/property in a wxPropertyGrid is visible after deleting the currently selected property?
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Ensure a row is visible in wxProprtyGrid

Post by ONEEYEMAN »

Hi,
What is the scenario where you want it?
The property grid has a scrollbar so user can always scroll to the appropriate property...

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Ensure a row is visible in wxProprtyGrid

Post by doublemax »

Did you try wxPropertyGrid::EnsureVisible(wxPGPropArg id) ?
https://docs.wxwidgets.org/trunk/classw ... 5991c7ae27
Use the source, Luke!
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Ensure a row is visible in wxProprtyGrid

Post by Widgets »

@doublemax I have looked at the function, but my problem is to get the appropriate xPGPropArg id
I have a property grid with a variable number of entries in a variable height window, a user might/will decide to delete any one of the properties, from the first to the last. I can find out which he selected and I can delete it, but I have not yet figured out how to ensure that the scrolled position is such after the delete, such that one of the adjacent properties is visible. ( Border case: delete the only entry. Unlikely case, but ought to be handled as well, though that might be the easier one, although I have not found even a way to get the count of entries)
There seems to be no way to select the next or previous sibling of a specific property at least I have not found any.
I have considered one option, which is to force a recreation of the contents. That would not be too difficult, but I was curious if there was a different way.
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Ensure a row is visible in wxProprtyGrid

Post by doublemax »

You can create a wxPGPropArgCls from a wxPGProperty.
https://docs.wxwidgets.org/trunk/classw ... g_cls.html

wxPGPropArg is just a reference to wxPGPropArgCls:

Code: Select all

typedef const wxPGPropArgCls& wxPGPropArg
If you call on EnsureVisible() on the item before you delete it, shouldn't that have the same effect?
Use the source, Luke!
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Ensure a row is visible in wxProprtyGrid

Post by Widgets »

doublemax wrote: Fri Oct 22, 2021 8:16 am If you call on EnsureVisible() on the item before you delete it, shouldn't that have the same effect?
For my current test cases, that actually works! :-)
Thank you
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
Post Reply