【问题标题】:Why don't I see the Designer View in Microsoft Visual Studio 2019?为什么我在 Microsoft Visual Studio 2019 中看不到设计器视图?
【发布时间】:2019-11-24 19:12:06
【问题描述】:

所以我一直在尝试使用设计器创建一个 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 的新手,所以我不知道如何继续。我试过用谷歌搜索它,但大多数情况下都会出现错误消息,而我只是显示了一个代码,无论我按什么。

【问题讨论】:

  • 您在错误列表中看到任何警告或错误吗?
  • 完全没有错误或警告。无论我按什么,即使是视图设计器,我都会被引导到代码视图,没有错误或警告。
  • 您使用的是 .Net Core 吗?如果是这样,它是一个已知的限制。看到这个:developercommunity.visualstudio.com/content/problem/752558/…
  • 显然我使用的是 .NET Core,直到我搜索它才列出框架选项。谢谢你的链接,我想我现在应该没事了。

标签: c# visual-studio


【解决方案1】:

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

您可以使用 .Net 框架

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-01
    • 2020-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多