How can I ensure that the top most property (as displayed in the grid
property) of the 'SelectedObject' is visible. For some reason, the property
grid is scrolled all the way down so the very last property is visible. I
need the property girdd to be scrolled all the way up so the very first
property is visible.



Carlos J. Quintero [.NET MVP]

Hi Roman,

Yes, there is a problem with that. Try this:

Friend Shared Sub SelectFirstGridItem(ByVal ctlPropertyGrid As PropertyGrid)

Dim objTopGridItem As GridItem
Dim objSelectedGridItem As GridItem

objSelectedGridItem = ctlPropertyGrid.SelectedGridItem

If Not (objSelectedGridItem Is Nothing) Then

objTopGridItem = GetTopGridItem(objSelectedGridItem)

If Not (objTopGridItem Is Nothing) Then
If objTopGridItem.GridItems.Count > 0 Then
ctlPropertyGrid.SelectedGridItem =
End If
End If

End If

End Sub

Private Shared Function GetTopGridItem(ByVal objGridItem As GridItem) As

Dim objResultGridItem As GridItem

If objGridItem.Parent Is Nothing Then
objResultGridItem = objGridItem
objResultGridItem = GetTopGridItem(objGridItem.Parent)
End If

Return objResultGridItem

End Function


Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:




Thanks Carlos,

It almost works. The code is fine and it does select the top grid item but
the problem is that it works only when I force the property grid (the
application) to repain and it is effective only when I do it manually by
manually switching between applications. Calling 'Invalidate' on the property
grid or even on the form hosting the grid does not do it. Any ideas?


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

PropertyGrid 0
PropertyGrid 0
PropertyGrid 1
PropertyGrid 4
PropertyGrid 1
PropertyGrid 6
PasswordChar and PropertyGrid 0
Propertygrid and exceptions 3