Monday, July 25, 2011

C# .NET 4 DataGridView doesn't display data after datasource is set

It took me an hour of searching and experimenting to discover the reason why the DataGridView wouldn't display any data when I bound lists of objects to it.

The DataGridView will not auto generate columns or display data of any kind if the objects in the list to which you are binding have only fields and not properties.

To fix the problem add a public property with a getter for each field for which you wish to display a column.

In my case I wasn't interested in properties because the classes in question were DataContracts where the fields were my focus.  The DataContract and DataMember attributes below are not required.

[DataContract]
public class FBAccount
{
     [DataMember(IsRequired = false)]
     public int id;
     public int Id
     {
            get { return id; }
     }
      ...

}

BindToGrid(object DataSource_)
{

            List accounts = DataSource_ as List;

            dataGridView1.AutoGenerateColumns = true;

            BindingSource bs = new BindingSource();

            bs.DataSource = accounts;              

            dataGridView1.DataSource = bs;

            bs.ResetBindings(true);

}

-Chris

Wednesday, July 20, 2011

Outlook Rules

Have you received the error message below in Outlook 2010 when you try to create a new email rule once you have about 50-150 rules?

There is not enough space on the Microsoft Exchange Server to store all of your rules. The rules that failed to upload have been deactivated.

If you're using Exchange server 2007 or 2010 you can increase the maximum space allocated for users' rules by following these instructions.

1)  Open exchange management shell.

2)  Display the rules quota for the email address in question.
Type "get-mailbox joesmith@superdeluxecompany.com | select name,rulesquota

3)  Set the rules quota to the maximum of 256KB:
Type "Set-mailbox joesmith@superdeluxecompany.com -RulesQuota:256KB"

4)  Check that setting the quota was successful:
Type "get-mailbox joesmith@superdeluxecompany.com | select name,rulesquota"

A restart of Outlook and possibly other steps for the new quota to take effect may be required, I'm not sure on this if someone knows the answer please leave a comment.

Credit for these instructions go to Anderson Patricio
They were originally given here http://msmvps.com/blogs/andersonpatricio/archive/2007/07/03/increasing-the-rules-quota-limit-in-exchange-server-2007.aspx

Links to some related Microsoft KBs on this issue none of which mention the solution detailed above.
http://support.microsoft.com/kb/241325/en-us
http://support.microsoft.com/?kbid=886616