PropertyGrid - Select and focus first property

Grids for WPF Forum

Posted 7 years ago by Wiley Knoch
Version: 16.1.0635
Avatar

I have a PropertyGrid I am showing on a popup dialog.  The requirement is when the dialog shows and the property grid is populated I need to select and put focus in the first (or any particular) property of the grid.

I have found several ways to do this using theItemContainerGenerator.ItemFromContainer to get the tree item and then set it selected.  But my problem is I need to do this as soon as the grid is populated and I cannot find any notification of when the visual tree for the grid is done.  Or maybe there is an even better way of handling this, any help is appreciated.

Comments (3)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Wiley,

Check out our PropertyGridSettingFocus QuickStart sample.  It shows an easy way to focus a property model.

I believe if you do that, even before containers are generated, it will flag which property model should get focus when its container is generated.  Worst case scenario if that didn't work, you could do your focus call after the propGrid.ItemContainerGenerator.StatusChanged event indicated containers were generated.


Actipro Software Support

Posted 7 years ago by Wiley Knoch
Avatar

Where do I find these QuickStart samples?

<EDIT, found it in the Browser sample application, thanks>

[Modified 7 years ago]

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

They are in the main sample project that gets installed by default and has samples for all our products.  That particular sample is in this relative path to the root of the project:

\ProductSamples\GridsSamples\QuickStart\PropertyGridSettingFocus


Actipro Software Support

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.