PropertyGrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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 =
objTopGridItem.GridItems.Item(0)
End If
End If

End If

End Sub

Private Shared Function GetTopGridItem(ByVal objGridItem As GridItem) As
GridItem

Dim objResultGridItem As GridItem

If objGridItem.Parent Is Nothing Then
objResultGridItem = objGridItem
Else
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:
http://www.mztools.com
 
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?

Roman
 
Back
Top