Showing posts with label binding. Show all posts
Showing posts with label binding. Show all posts

Sunday, January 29, 2012

netsh

Everytime I write a new WCF service that uses http, I find myself searching my memory for this simple but yet forgettable simple command:
netsh http add urlacl url=http://+:8080/IService/ user=\Everyone
Now I know where to find it ;-).

And for those who are not familiar with this command, netsh http add urlacl as the MSDN states: assigns the rights for a portion of the HTTP URL namespace to a particular group of users.

More information about netsh.

So now we have the permission to run the self hosted service locally.

Thursday, July 22, 2010

Overriding ExpandableObjectConverter::GetProperties

Today I was faced with a BrowsableAttribute problem:

I had a collection that I needed to be able to select from a PropertyGrid, but also be able to edit the items and their properties with a DataGridView. I wanted the PropertyGrid to show only the item name in an expandable control and to be able to edit all the items property in the DataGridView.

When using BrowsableAttribute I had a problem that each time I would have to set the value according to the requesting control. I solved this by overriding ExpandableObjectConverter::GetProperties. I went over the PropertyDescriptorCollection and removed each property I didn't want:

public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
{
PropertyDescriptorCollection collection = base.GetProperties(context, value, attributes);
PropertyDescriptor[] final = new PropertyDescriptor[1];
foreach (PropertyDescriptor descriptor in collection)
{
if (descriptor.Name == "ItemName")
final[0] = descriptor;
}
return new PropertyDescriptorCollection(final);
}

Now when binding the list to DataGridView I would see all the properties, and when expanding the list in PropertyGrid I would see only the Item Name Property.