Q: Ordering/Sorting [Category] text in a PropertyGrid

  • Thread starter Thread starter Robert Hooker
  • Start date Start date
R

Robert Hooker

Hi all,

I'm looking for a way to sort/order the Category text items in a property
grid. The grids sort the categories by alpha when the catergories are
displayed.
Does anyone at Microsoft (or anywhere else) no of a way that we can override
that sort/order for the category text?

[ We have implemented a fair amount of code to sort/order individual items
in a property grid the way we want them, but haven't found any at all yet to
do the same for Category text...]

Rob.
 
Robert,

I don't believe there is a way to do this. The only thing that I could
find that indicates you might be able to do this is the PropertySort
property. If you set it to none, it says that the properties are displayed
in the order that they are received from the type descriptor. You might be
able to create a proxy type descriptor between your object and the
propertygrid, which would then return not only the properties in the correct
order, but the properties with the categories in the order that you want
them in.

Hope this helps.
 
We've tried this - unfortunately it doesn't work. When we return the
PropertyDescriptorCollection collection, it is correctly sorted the way we
want it (categories and all), but the propertygrid simply ignores that order
for the category texts. It *does* respect the order for individual
properties within each category though...


Nicholas Paldino said:
Robert,

I don't believe there is a way to do this. The only thing that I could
find that indicates you might be able to do this is the PropertySort
property. If you set it to none, it says that the properties are displayed
in the order that they are received from the type descriptor. You might be
able to create a proxy type descriptor between your object and the
propertygrid, which would then return not only the properties in the correct
order, but the properties with the categories in the order that you want
them in.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Robert Hooker said:
Hi all,

I'm looking for a way to sort/order the Category text items in a property
grid. The grids sort the categories by alpha when the catergories are
displayed.
Does anyone at Microsoft (or anywhere else) no of a way that we can override
that sort/order for the category text?

[ We have implemented a fair amount of code to sort/order individual items
in a property grid the way we want them, but haven't found any at all
yet
to
do the same for Category text...]

Rob.
 
There is no Documented or supported way to do it and nothing is exposed to allow it... I suppose its possible to 'hack' something but I haven't seen anything to indicate anyone
has.

Want to know more? Check out the MSDN Library at http://msdn.microsoft.com or the Microsoft Knowledge Base at http://support.microsoft.com

Scot Rose, MCSD
Microsoft Visual Basic Developer Support
Email : (e-mail address removed) <Remove word online. from address>

This posting is provided “AS IS”, with no warranties, and confers no rights.




--------------------
 
Using "non-printable' characters works a treat.
For everyone else struggling with category ordering\sorting, to achieve
this:

+Z First Category
+ some props
+T Second Category
+ other props
+ A third category
+ more props

You can do this:
[Category("\t\tZ First Category]
[Category("\tT First Category]
[Category("A third Category]

It seems the PropetyGrid includes the "tabs" for the purposes of sorting,
but excludes them when it actually renders the text in the cell.

Rob.
 
Back
Top