c# - Visual Studio 设计器 View 无法获得正确的形式

标签 c# winforms visual-studio-2010 windows-forms-designer

我在 C# 中有 GUI 项目。主窗口类的定义如下所示:

FormView.cs文件

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace RssReader
{
    partial class FormView : Form, IView
    {
        private SplitContainer MainContainer;
        private TreeView Items;
        private MenuStrip MainMenu;
        private ToolStripMenuItem File;
        private ToolStripMenuItem AddFeed;
        private ToolStripSeparator Separator;
        private ToolStripMenuItem Quit;
        private WebBrowser Message;

        /* some methods here which are implementing some kind of logic */
    } 
}

FormViewInit.cs文件

namespace RssReader
{
    partial class FormView
    {
        private void InitializeComponent()
        {
            this.MainContainer = new System.Windows.Forms.SplitContainer();
            this.Items = new System.Windows.Forms.TreeView();
            this.Message = new System.Windows.Forms.WebBrowser();
            this.MainMenu = new System.Windows.Forms.MenuStrip();
            this.File = new System.Windows.Forms.ToolStripMenuItem();
            this.AddFeed = new System.Windows.Forms.ToolStripMenuItem();
            this.Separator = new System.Windows.Forms.ToolStripSeparator();
            this.Quit = new System.Windows.Forms.ToolStripMenuItem();

            // the only component in this file is InitializeComponent method
            // all, what it does is just defining items on the form
            // and initializing it, i.e., creating instances, assign names etc.
        }
    }
}

FormViewEventHandlers.cs文件

using System;
using System.IO;
using System.Windows.Forms;

namespace RssReader
{
    partial class FormView
    {

        private void Quit_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Do you really want to quit?", "Exit", MessageBoxButtons.YesNo)
                == DialogResult.Yes)
                Application.Exit();
        }

        // here goes event handler functions
    }
}

问题是:当我尝试在 visual studio 2010 的设计 View 中查看 FormView.cs 时,为什么我得到的表单大小错误且没有元素?

最佳答案

您的 FormView 中是否有构造函数?如果是,是否调用了 InitializeComponent() 方法?

关于c# - Visual Studio 设计器 View 无法获得正确的形式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10211223/

相关文章:

c# - 该类型不能用作泛型类型或方法 'T' 中的类型参数 'BaseController<T>' 。没有隐式引用

c# - 无法从热门匹配中获取对象

c# - 将 SQL 数据库存储在对象中?

c# - 如何使用 slider 在两个 TreeView 中同步滚动

c# - 在时间范围内对获取项目进行分组

c# - 在 IDE 中对 C# 程序集进行签名与使用signtool.exe进行签名

C# - 只有字母和数字的文本框

android - 包含 Windows 7 手机项目的解决方案中的 MonoDroid 项目?

c++ - 创建 boost::tuple<std::string, std::string, int> 和 std::vector<int> 的映射

visual-studio-2010 - 升级到 Visual Studio 2010 时出现问题