Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6117549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:20:00+00:00 2026-05-23T15:20:00+00:00

I have ProperyGrid loaded with categorised PropertySpec and set to CategorizedAlphabetical sort. When form

  • 0

I have ProperyGrid loaded with categorised PropertySpec and set to CategorizedAlphabetical sort. When form runs categories then items within categories are sorted. An annoying artefact is that PropertyGrid by default selects the first item after list was sorted and sometimes it scrolls view to selection. If item list is long you end up seeing list scrolled to somewhere in the middle.

Since PropertySpec can be created at runtime I want to always show the top of list on form load. PropertyGrid does not ‘easily’ expose collections and certainly not in ordered sequence. After googling around I am lead to believe this is not possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:20:01+00:00Added an answer on May 23, 2026 at 3:20 pm

    I came up with below code which proves otherwise.

    Snippet will select fist category of sorted list. One could also select first item in that category expanding on the method but for my needs that was unnecessary.

    // bind the PropertyTable to PropertyGrid
    this.pg_Prefs.SelectedObject = proptable;
    
    // get selected item
    GridItem gi = this.pg_Prefs.SelectedGridItem;
    // get category for selected item
    GridItem pgi = gi.Parent.Parent;
    
    //sort categories
    List<GridItem> sortedCats = new List<GridItem>(pgi.GridItems.Cast<GridItem>());
    sortedCats.Sort(delegate(GridItem gi1, GridItem gi2) { return gi1.Label.CompareTo(gi2.Label); });
    
    // loop to first category
    for (int i = 0; i < pgi.GridItems.Count; i++)
    {
        if (pgi.GridItems[i] == gi) break; // in case full circle done
        // select if first category
        if (pgi.GridItems[i].Label == sortedCats[0].Label)
        {
             pgi.GridItems[i].Select();
             break;
        }
    }
    

    Hope this will help others as well.

    The simplified method of actually selecting category once you have sorted list would be to sortedCats[0].Select(); instead of looping through and checking each item. You would have to assert the list is not empty if you wanted to use that shortcut but that would gives some performance improvement…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of custom PropertyDescriptor that I want to add categories too
I have a PropertyGrid on my form. My boss thinks it's ugly. Uncouth. Unsophisticated.
I have access to a 3rd party PropertyGrid within my application (C#. ,Net v2).
I have an object that in a simplified form is as follows: public class
I have a control extending PropertyGrid which allows users to set the properties of
I have a Windows form (.NET 3.5) that contains a propertygrid control. The propertygrid
I have a custom control that has an Items property. I Have applied an
I have a Windows application that uses a .NET PropertyGrid control. Is it possible
Have just started using Google Chrome , and noticed in parts of our site,
Have you ever seen any of there error messages? -- SQL Server 2000 Could

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.