First displayed item in a PropertyGrid

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

Guest

I want to set PropertyGrid.SelectedGridItem to the first item that is
displayed in a PropertyGrid. Note that the first item that is displayed
depends on the value of PropertyGrid.PropertySort. Are there any methods
that can help with determining the first displayed item in a PropertyGrid?

Thanks,
Lance
 
Cor,

Cor Ligthert said:
I was awarded me that as well when I had sent this, I readed PropertyGrid
as the new grid in WhidBey, however did not correct that, because I was
sure you would do that.


No problem :-). I didn't see that the OP posted some other Whidbey-related
questions.
 
Hi,

I think we may try to iterate throught the propertygrid's item and call the
select method on the first one.

private void button1_Click(object sender, System.EventArgs e)
{
GridItem gi=propertyGrid1.SelectedGridItem;
if (this.propertyGrid1.PropertySort == PropertySort.Alphabetical )
{
GridItem p_gi=gi.Parent;
foreach( GridItem egi in p_gi.GridItems)
System.Diagnostics.Debug.WriteLine(egi.Label);
p_gi.GridItems[0].Select();
}
else
{
GridItem p_gi=gi.Parent.Parent;
foreach( GridItem egi in p_gi.GridItems)
{
System.Diagnostics.Debug.WriteLine("");
System.Diagnostics.Debug.WriteLine(egi.Label);
foreach( GridItem eegi in egi.GridItems)
System.Diagnostics.Debug.WriteLine(eegi.Label);
}
p_gi.GridItems[0].GridItems[0].Select();
}
}

Hope this helps.

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top