这是我的dialogform的代码
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;namespace TextEditor
{
/// <summary>
/// DialogForm 的摘要说明。
/// </summary>
public class DialogForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public DialogForm()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
// 
// btnOK
// 
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOK.Location = new System.Drawing.Point(16, 200);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(72, 32);
this.btnOK.TabIndex = 0;
this.btnOK.Text = "&OK";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
// 
// btnCancel
// 
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(176, 200);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(72, 32);
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "&Cancel";
// 
// DialogForm
// 
this.AcceptButton = this.btnOK;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(292, 247);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
  this.btnCancel,
  this.btnOK});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "DialogForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "DialogForm";
this.Load += new System.EventHandler(this.DialogForm_Load);
this.ResumeLayout(false); }
#endregion private void btnOK_Click(object sender, System.EventArgs e)
{

} private void DialogForm_Load(object sender, System.EventArgs e)
{

}
}
}继承出来的OptionForm代码
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;using System.Windows.Forms;namespace TextEditor
{
public class OptionForm : DialogForm
{
private System.ComponentModel.IContainer components = null; public OptionForm()
{
// 该调用是 Windows 窗体设计器所必需的。
InitializeComponent(); // TODO: 在 InitializeComponent 调用后添加任何初始化
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null) 
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

解决方案 »

  1.   

    懒得看完你的代码,因为我用vb.net,不用c#,所以也没有实验你的代码。
    现在只提一些注意事项:
    1、基类窗体不能还有虚方法,否则子类窗体无法可视化修改。
    2、基类窗体中的控件,只有定义成public或者protected,才能在子类窗体中进行属性设置。
      

  2.   

    先建一个标准的窗体,在代码中进行继承,在同一文件中,VS.NET的设置器不支持向导方式进行继承.
      

  3.   

    你看看基类窗体中的控件的属性Modifiers是否为private,应该定义为public或protected
      

  4.   

    我也试了一下,VB.NET是可以的,为什么C#不行,还是Visual Studio.NET的bug吧。