This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, The first time I set the grid's SelectedObject to something, the left column width sizes to fit the longest property name. But from then on, the left column width does not change size as I select other objects. Is there a way to command the grid to always auto size the left column to fit the longest property name? Thanks Tom |
|
|
Hi Tom, We don't currently have that feature but will add it to the wishlist. I'm afraid I don't have any great ideas for a workaround either unfortunately. Here is my best suggestion (untested!): The columns are defined in the PropertyGrid default template, which is implemented as a TreeListView. To get at this TreeListView, you need to derive from PropertyGrid; this is necessary to call the protected method GetTemplateChild. So create a derived class with an "autosize now" method. In that method, call GetTemplateChild("PART_Grid"). If this returns a TreeListView (which it will in the default template), set TreeListView.Columns[0].Width to Double.NaN (the magic number for autosize). |
|
|
Setting TreeListView.Columns[0].Width in the derived class method does change the column width, but the value Double.NaN doesn't seem to have any effect. So I call TextRenderer.MeasureText() on all the nodes and set the column to the width of the longest human name I find. It works well. Thanks. |
|