Microsoft KB Archive/818811

From BetaArchive Wiki
Knowledge Base


Article ID: 818811

Article Last Modified on 5/12/2007



APPLIES TO

  • Microsoft .NET Framework 1.1
  • Microsoft .NET Framework 1.0



SYMPTOMS

If you try to set the value of the BrowsableAttribute property to TRUE during design time in Microsoft Visual Studio .NET, and if the control class has certain types of properties, you receive the following error message:

Invalid property value

The following are the types of control class properties that this situation applies to:

  • PointF
  • SizeF
  • RectangleF


CAUSE

This problem occurs because predefined type converter classes are not available for the structures that are listed in "Symptoms". The default converters for the classes are as follows:

Class Default Converter
Point PointConverter
Size SizeConverter
Rectangle RectangleConverter


Note You cannot use these default converters as the type converters for PointF, SizeF and RectangleF.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

WORKAROUND

To work around this problem, use one of the following methods:

Use different types for the properties that are to be exposed by the control:

Instead of this property: Use this property:
PointF Point
SizeF Size
RectangleF Rectangle


- or -

Use type converters for PointF, SizeF and RectangleF.

For more information about how to write type converters, see the "References" section of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a Microsoft Visual C# Windows Control Library in Visual Studio .NET.
  2. Add the following code to the code that the wizard generated for the user control class:

    private PointF m_Point;
    
    [Browsable(true)]
    [TypeConverter("System.Drawing.PointConverter, System.Drawing")]
    public PointF Position
    {
        get
        {
            return m_Point;
        }
        set
        {
            m_Point = value;
        }
    }
  3. Build the application.
  4. Create a Visual C# Windows application in Visual Studio .NET.
  5. Right-click Windows Forms Toolbox, and then click Customize Toolbox.
  6. In the Customize Toolbox dialog box, select the .NET Framework Components check box, and then click Browse.
  7. In the Open dialog box, specify the path of the dynamic link library (DLL) that you created for the Windows Control Library (steps 1 to 3), and then click Open.
  8. Click OK to close the Customize Toolbox dialog box.
  9. Drag the user control from the Windows Forms Toolbox onto the design view.
  10. Right-click the control on the design view, and then click Properties.
  11. Scroll to the Position property that is under the Misc section.

    If you modify the value of this property, you receive the error that is mentioned in the "Symptoms" section.


REFERENCES

For additional information about implementing a type converter, see the following MSDN documentation:


For additional information about design time support that is available in Visual Studio .NET, see the following MSDN documentation:

Keywords: kbdswgdi2003swept kbide kbcontrol kbprb KB818811