First displayed item in a PropertyGrid

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
 
H

Herfried K. Wagner [MVP]

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.
 
P

Peter Huang [MSFT]

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.
 

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

Top