首页 > 解决方案 > 为什么我在 Microsoft Visual Studio 2019 中看不到设计器视图?

问题描述

所以我一直在尝试使用设计器创建一个 Windows 窗体(将元素拖放到窗口,移动它们等等),但不幸的是,我只能看到代码。

我添加了一个新的 Windows 窗体 - PhoneBookDisplay.cs。当我双击它时,我看到了这段代码:

using System.Windows.Forms;

namespace EvenTool
{
    public partial class PhoneBookDisplay : Form
    {
        public PhoneBookDisplay()
        {
            InitializeComponent();
        }
    }
}

当我用鼠标右键按下它时,会出现 View Designer (Shift+F7) 选项,我按下但没有任何反应,提示我使用与上面相同的代码。

还有包含此代码的 PhoneBookDisplay.Designer.cs 文件:

namespace EvenTool
{
    partial class PhoneBookDisplay
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(800, 450);
            this.Text = "PhoneBookDisplay";
        }

        #endregion
    }
}

当我调用 View Designer 选项时,我被重定向到第一个示例中的代码。所以我基本上无法使用工具箱进行设计,我可以在其中拖放按钮等元素。

我是 Visual Studio 的新手,所以我不知道如何继续。我试过用谷歌搜索它,但大多数情况下都会出现错误消息,而我只是显示了一个代码,无论我按什么。

标签: c#visual-studio

解决方案


提供的代码看起来是正确的。但是,当您使用带有 .Net Core 的 Windows 表单时,您无法打开设计器。这是当前版本的 Visual Studio 中的一个已知限制。见这里

您可以使用 .Net 框架


推荐阅读