我在 VS2005 中创建了一个 Interop 用户控件。当用户控件显示在 VB6 中时,它不会拾取/使用 XP 样式(按钮和选项卡看起来像 VB6 按钮/选项卡)。
在 VB6 中,如何让 XP 样式与我的控件一起使用?
您需要为应用程序添加清单文件,将名称为 {exefilename}.exe.manifest 的文件添加到与应用程序相同的文件夹中。
清单文件仅适用于 .net 的早期版本,在 .net 1.1 之后,您可以通过编程方式激活它们。我必须Application.EnableVisualStyles()
在互操作用户控件的默认构造函数中添加该行。
Public Sub New()
Application.EnableVisualStyles() '-- I added this line
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
'Raise Load event
Me.OnCreateControl()
End Sub
这是微软的帖子,Application.EnableVisualStyles
它解释了一切。