views:

584

answers:

1

I'm using a PropertyGrid in a tool app to show a window to monitor an object in a remote app. Every second or so I get an update from the app with the state of any members that have changed, and I update the grid. I call Refresh() to make the changes take. This all works pretty well except one thing.

Say the object is too tall to fit in the grid so there's a scrollbar. The user has selected a grid item but has also scrolled up above it so that the selected item is below the bottom of the control.

The problem is that on Refresh() the control automatically scrolls the grid item into view (strangely it doesn't do this when the item is above the top of the control).

I'm looking for a way to either prevent this, or to save state, do the Refresh(), and then set it back. I tried getting the underlying VScrollBar in the PropertyGridView inside the PropertyGrid, and messing with "Value", but it doesn't stay permanently set. Always pops back so the item is in view.

Deselecting the item during scrolling is my fallback (the auto scroll-into-view doesn't happen with no selected grid item) but it hurts the usability a little so I'm looking for another way.

Anyone run into something similar?

+2  A: 

This is not possible in the MS PropertyGrid. This component has too many unaccessible internals to give you the flexibility you are requesting and as you realized yourself it is not consistent (you have the issue for a property below the grid but not when it is above). That's why I created Smart PropertyGrid.Net. If a commercial product is an option for you, this grid has the option to store property states and restore them after you made an action on the grid (like Refresh()) without any flicker.

Nicolas Cadilhac
I'm definitely pushing past the limits of PropertyGrid in a number of ways. PropertyGridEx got me pretty far, but much more of this and I'll have to consider a commercial solution. Limping along for now... Still, that I got as much as I did out of it is a testament to the .NET team! Yay for reuse!
Scott Bilas