It almost works. The code is fine and it does select the top grid item but
manually switching between applications. Calling 'Invalidate' on the property
grid or even on the form hosting the grid does not do it. Any ideas?
"Carlos J. Quintero [.NET MVP]" wrote:
> 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 >
> "Roman" <Roman@discussions.microsoft.com> escribió en el mensaje
> news:DAB2A6E2-87E8-4135-BDEF-FDC092F72A24@microsoft.com...
> > 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.
>
>