properties sort order
-
I binded an employee class to the propertygrid control in C#. It's now displaying as follows: MiddleName FirstName LastName Age ID How can I show ID at the very top, then lastname, first name and middle name. I didn't find any property that could do. Is there something i am missing. thanks
-
I binded an employee class to the propertygrid control in C#. It's now displaying as follows: MiddleName FirstName LastName Age ID How can I show ID at the very top, then lastname, first name and middle name. I didn't find any property that could do. Is there something i am missing. thanks
When you bind an obect to a property grid, it uses reflection to walk through the properties exposed on the object. I would hazzard to guess, based on the little bit of data you provided, is that those are the order that the properties exist in your Employee Class ??!! One thing to do is to try changing the order. There are also a number of decorators you can use to help with what the property grid exposes. For example [Description()] will populate the decriptor box at the bottom of the property grid when you click on the field. Most of the behavior is not controlled by properties on the grid, but rather the decorators on your fields.
-
I binded an employee class to the propertygrid control in C#. It's now displaying as follows: MiddleName FirstName LastName Age ID How can I show ID at the very top, then lastname, first name and middle name. I didn't find any property that could do. Is there something i am missing. thanks
hi, I would create a TypeConverter for your employee class (derived from ExpandableObjectConverter). Its GetProperties method would then return something like: return TypeDescriptor.GetProperties(typeof(Employee), attributes).Sort(new string[] { "ID" }); The GetPropertiesSupported method must return true too. If you need to specify the order after "ID", pass more strings in the array. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker