Business Object Properties in Random Order
-
How can I control the order that my properties appear in the DataBindings BindingSource selection dialog? Sorted alphabetic would be nice. I have a business object that inherits from a bindingsource. Its properties appear to be in an apparent random order in the binding source selection dialog. For example when I'm selecting a property to bind to a text box text property.
-
How can I control the order that my properties appear in the DataBindings BindingSource selection dialog? Sorted alphabetic would be nice. I have a business object that inherits from a bindingsource. Its properties appear to be in an apparent random order in the binding source selection dialog. For example when I'm selecting a property to bind to a text box text property.
I'm thinking you might be able to do something like that by inheriting from ExpandableObjectConverter. I'm not sure, but it'll give you something to try out.
public class MyClass : ExpandableObjectConverter
{
// ... additional code including Name and Value propertiespublic override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return true;
}public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
{
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value, attributes);
return properties.Sort(new string[] {"Name", "Value"});
}
} -
I'm thinking you might be able to do something like that by inheriting from ExpandableObjectConverter. I'm not sure, but it'll give you something to try out.
public class MyClass : ExpandableObjectConverter
{
// ... additional code including Name and Value propertiespublic override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return true;
}public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
{
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value, attributes);
return properties.Sort(new string[] {"Name", "Value"});
}
}That was just the lead that I needed. I'm inheriting from a bindingsource and it implements ITypedList which has the GetItemProperties function. I overrode that function and simply added .Sort to base.GetItemProperties(listAccessors) Thanks
-
That was just the lead that I needed. I'm inheriting from a bindingsource and it implements ITypedList which has the GetItemProperties function. I overrode that function and simply added .Sort to base.GetItemProperties(listAccessors) Thanks