Hi,
You are right, simply adding the DefaultPropertyAttribute on the class being used as the PropertyGrid.SelectedObject will do the job.
You are right, simply adding the DefaultPropertyAttribute on the class being used as the PropertyGrid.SelectedObject will do the job.
[DefaultProperty("ID")]
public class Person
{
public string FirstName
{
get;
set;
}
public string LastName
{
get;
set;
}
public int ID
{
get;
set;
}
}
---------------------------
_propertyGrid.SelectedObject = new Person()
{
FirstName = "Bob",
LastName = "Jones",
ID = 34
};
When opening the propertyGrid, you should see the ID property being highlighted.