我在 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 的设计视图中查看 FormView.cs 时,为什么我得到一个尺寸错误且没有元素的表单?