Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: How can I select a specific property in the property grid in code

$
0
0
Hi,

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.

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>