当自定义控件所在的dll中出现了DllImport 属性时候,自定义类型的控件属性就不能正常显示在属性窗口了
通过将 DesktopCompatible(true) 属性放置在父窗体或父用户控件中,可以安全地启用可视继承
先在项目中添加一个“设计时属性文件”默认名为DesignTimeAttributes1.xmta
然后在其中添加如下节点
- <Class Name="SmartDeviceProject1.Form1">
- <DesktopCompatible>true</DesktopCompatible>
- </Class>
SmartDeviceProject1.Form1为被继承的类名,
ok,这样应该就能解决问题了
如果自己写的控件类,需要在设计视图中显示内容也可以通过在此文件中添加如下节点:
- <Class Name="ImageButton">
- <DesktopCompatible>true</DesktopCompatible>
- <Property Name="Size">
- <DefaultValue>
- <Type>System.Drawing.Size, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Type>
- <Value>16, 16</Value>
- </DefaultValue>
- </Property>
- </Class>