1

我继承了一些用 Visual Studio 2010 编写的针对 .NET 2.0 框架的 C# 源代码。它包含一个简单的 Windows 窗体应用程序,其用户界面为单个窗体。

该表单包含许多菜单项,其中一个允许用户预览图像(从相机获取)。程序输出的示例如下所示,黑色矩形是图像。

NET2 Windows 窗体 (VS 2010)

我希望使用 Visual Studio 2019 从头开始​​为 .NET 4.6.2 框架重写应用程序。

重新创建表单很简单。但是,MenuItemVS2010 中用于 .NET 2.0 的组件已被MenuStripVS2019替换ToolStripMenuItem。当我构建应用程序的更新版本时,我无法使菜单条以相同的方式运行。当应用程序运行时,我的输出如下所示。

NET4.6.2 Windows 窗体(VS2019)

如您所见,顶级菜单可访问但不可见。如何找到下面的工作区图像MenuStrip

我希望答案是MenuStrip我忽略的 Visual Studio 的“属性”对话框中的一些设置。

以下是属性当前在 中的显示方式Form1.Designer.cs

        // mainMenu1
        // 
        this.mainMenu1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.menuFile,
        this.menuView,
        this.menuSet,
        this.menuDLL,
        this.menuDevice});
        this.mainMenu1.Location = new System.Drawing.Point(0, 0);
        this.mainMenu1.Name = "mainMenu1";
        this.mainMenu1.Size = new System.Drawing.Size(641, 24);
        this.mainMenu1.TabIndex = 0;
        this.mainMenu1.Text = "menuMenu1";
4

1 回答 1

0

For anyone who may be interested in this problem, I didn't solve it but managed to find a workaround by offsetting the image by +25 along the y-axis.

I didn't use the WinForm Properties to do this. The code that I have inherited uses a third party dll to create the preview. I'm not sure how the dll handles the window size and positioning but I think that it overrides any WinForm property that I try to apply.

Sorry that my answer doesn't help those looking to solve their own version of this problem.

于 2022-01-04T21:10:37.840 回答