views:

48

answers:

0

Running the following 39 lines of a minimal Windows Forms PropertyGrid shows an unexpected behavior on a Windows Server 2008 Enterprise machine:

using System;
using System.Windows.Forms;

namespace MinimalPropertyGrid
{
    public sealed class SomeType
    {
        public Kind Kind { get; set; }
    }

    public enum Kind
    {
        Default,
        Unknown
    }

    sealed class Form1 : Form
    {
        public Form1()
        {
            PropertyGrid propertyGrid = new PropertyGrid();
            propertyGrid.Dock = DockStyle.Fill;
            propertyGrid.SelectedObject = new SomeType();

            this.Controls.Add(propertyGrid);
        }
    }

    static class Program
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

After expanding the automatically generated drop down list for the one and only property, the result looks like the left part of the following screenshot on Windows Server 2008 Standard (64bit).

I have also tried this successfully on Vista (32bit), Windows XP (32bit) and Windows 7 (64bit).

But on a host running Windows Server 2008 Enterprise (64bit) the drop down list contains empty items - see the right part of the previous screenshot.

What the screenshot does not show: There are really the two items in the list and I can select them - when the drop down list disappears the selected item's value is correctly displayed.

I am experiencing this problem in a real-world application with types dynamically providing their standard values at runtime. To help in understanding the problem, I have reduced the code to the provided sample above.

I am completely unsure which aspect is causing this behavior. The System.Windows.Forms assembly on both Windows Server 2008 systems have the same version (2.0.50727.4016). After some time I have installed Visual Studio 2008 on this Windows Server 2008 Enterprise machine - the built-in PropertyGrid does not show this strange behavior.

Is this a known issue? What can I try to resolve this problem?

Thanks for reading this far!

related questions