uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls; type
TForm1 = class(TForm)
pnl1: TPanel;
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} end.
//---------
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Unit1, ExtCtrls; type
TForm2 = class(TForm1) // 继承于TForm1类
pnl2: TPanel;
private
{ Private declarations }
public
{ Public declarations }
end; var
Form2: TForm2; implementation {$R *.dfm} end.

代码

object Form1: TForm1
Left =
Top =
Width =
Height =
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch =
TextHeight =
object pnl1: TPanel
Left =
Top =
Width =
Height =
Caption = 'pnl1'
Color = clSkyBlue
TabOrder =
end
end
//------------
inherited Form2: TForm2
Width =
Height =
Caption = 'Form2'
PixelsPerInch =
TextHeight =
inherited pnl1: TPanel
Left =
Top =
Width =
Height =
end
object pnl2: TPanel
Left =
Top =
Width =
Height =
Caption = 'pnl2'
Color =
TabOrder =
end
end

窗体代码

Delphi2C#工具转换后,有异常无法编译

仅需要改 //Unit2.Designer.cs

namespace Unit2
{
partial class TForm2
{
public System.Windows.Forms.Panel pnl1;
public System.Windows.Forms.Panel pnl2; #region Windows Form Designer generated code
private void InitializeComponent()
{
this.pnl1 = new System.Windows.Forms.Panel();
this.pnl2 = new System.Windows.Forms.Panel();
this.pnl1.Size = new System.Drawing.Size(, );
this.pnl1.Location = new System.Drawing.Point(, );
this.pnl1.Enabled = true;
this.pnl1.Name = "pnl1";
this.pnl1.BackColor = System.Drawing.SystemColors.ButtonFace;
this.pnl2.Size = new System.Drawing.Size(, );
this.pnl2.Location = new System.Drawing.Point(, );
this.pnl2.Enabled = true;
this.pnl2.TabIndex = ;
this.pnl2.Name = "pnl2";
this.pnl2.Text = "pnl2";
this.pnl2.BackColor = ;
}
#endregion }
}

这是生成的默认代码

//这是修改后的代码
namespace Unit2
{
partial class TForm2
{
//public System.Windows.Forms.Panel pnl1;// 第一处屏蔽
public System.Windows.Forms.Panel pnl2; #region Windows Form Designer generated code
private void InitializeComponent()
{
//this.pnl1 = new System.Windows.Forms.Panel(); 第二 屏蔽
this.pnl2 = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// pnl1
//
this.pnl1.BackColor = System.Drawing.SystemColors.MenuHighlight; //第二并列 在窗体改panel颜色,就自动加了这三句话
this.pnl1.Location = new System.Drawing.Point(, );
this.pnl1.Size = new System.Drawing.Size(, );
//
// pnl2
//
this.pnl2.BackColor = System.Drawing.Color.AliceBlue;//第三改颜色值
this.pnl2.Location = new System.Drawing.Point(, );
this.pnl2.Name = "pnl2";
this.pnl2.Size = new System.Drawing.Size(, );
this.pnl2.TabIndex = ;
this.pnl2.Text = "pnl2";
//
// TForm2 //第四 加以下一段代码
//
this.ClientSize = new System.Drawing.Size(, );
this.Controls.Add(this.pnl2);
this.Location = new System.Drawing.Point(, );
this.Name = "TForm2";
this.Text = "Form1-form2";
this.Controls.SetChildIndex(this.pnl1, );
this.Controls.SetChildIndex(this.pnl2, );
this.ResumeLayout(false); }
#endregion }
}

、、-----------以下为错误的,不用看

using System;
using System.Windows.Forms;
using Unit1;
using Unit2;
namespace Project1.Units
{
public class Project1
{
// Form1
// Form2
[STAThread]
public static void Main(string[] args)
{
// Application.Initialize;
Unit1.Units.Unit1.Form1 = new TForm1();
Unit2.Units.Unit2.Form2 = new TForm2();
// Application.Run;
Application.Run(Unit2.Units.Unit2.Form2);//改第一处,这默认是Form1先启动,要改成Form2
} } // end Project1 }

改第一处

namespace Unit1
{
partial class TForm1
{
public System.Windows.Forms.Panel pnl1;
private System.ComponentModel.Container components = null;
private System.Windows.Forms.ToolTip toolTip1 = null; // Clean up any resources being used.
protected override void Dispose(bool disposing)
{
if(disposing)
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
} #region Windows Form Designer generated code
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(this.GetType());
this.components = new System.ComponentModel.Container();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.pnl1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
this.Location = new System.Drawing.Point(, );
this.ClientSize = new System.Drawing.Size(, );
this.Font = new System.Drawing.Font("MS Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point ,((byte)()));
this.BackColor = System.Drawing.SystemColors.ButtonFace;
this.Name = "Form1";
this.Text = "Form1";
this.AutoScroll = true;
this.pnl1.Size = new System.Drawing.Size(, );
this.pnl1.Location = new System.Drawing.Point(, );
this.pnl1.Enabled = true;
this.pnl1.TabIndex = ;
this.pnl1.Name = "pnl1";
this.pnl1.Text = "pnl1";
this.pnl1.BackColor = ; //System.Drawing.Color.SkyBlue; 改第二处,这里要写成这样的格式
this.Controls.Add(pnl1);
this.ResumeLayout(false);
}
#endregion }
}

改第二处

B窗体继承于A窗体,B启动:问题点的更多相关文章

  1. vb.net之窗体继承

    相信很多自己动手敲过完整程序的同学都会发现,其实我们敲的很多窗体布局都非常的相似,有的部分用到的控件甚至一模一样,如果每一个窗体都自己重新摆放或者复制粘贴虽然没有问题,但是有时候若是修改其中一小点位置 ...

  2. windows窗体继承问题

    窗体继承什么时候用的到呢?当我们使用三层架构来编写我们的cs程序时,我们的U层大部分是windows窗体.这个时候如果我们有一些公共变量,或者是一个窗体需要使用另一个窗体的数据.或者是有一些用于判断的 ...

  3. Delphi - 子窗体继承父窗体后如何显示父窗体上的控件

    1.创建子窗体Form1 File -> New -> Form,新建一个form,在form的单元文件中修改 2.子窗体中引用父窗体单元 uses TFatherForm 3.将子窗体中 ...

  4. WinForm窗体继承

    在Windows应用程序中,从现有的窗体继承,查看子窗体的设计视图时,会出现错误: 服务容器中已存在服务 System.Windows.Forms.Design.IEventHandlerServic ...

  5. WinForm窗体继承自定义的模板窗体出错

    在开发Winform程序的时候,我们往往需要根据需要做一些自定义的控件模块,这样可以给系统模块重复利用,或者实现更好的效果等功能.而今天自定义一个窗体,然后子窗体继承的时候出现了一点问题. 问题: 在 ...

  6. .NET重构(四):窗体继承+模板方法,完美实现组合查询

    导读:在机房重构中,有好些个查询都是大同小异,最为显著的就是组合查询了.怎样给自己省事儿,相同的东西能不能重复利用,就成了一个现实的问题.第一遍做机房的时候,使用的更多的是:复制+粘贴.学习了设计模式 ...

  7. PyQt5学习笔记-从主窗体打开一个子窗体

    PyQt5学习笔记-从主窗体打开一个子窗体 软件环境: Eric6+Python3.5+PyQt5 试验目标: 1.点击菜单项Open,打开一个子窗体 2.点击按钮Open,打开一个子窗体 主窗体设计 ...

  8. winform里操作打开在panel里的form窗体,子窗体操作同级子窗体或者父窗体的方法

    最近开始了一个winform项目,原先一直都是web项目.遇到个问题,就是在框架内,左侧和中间的main都是用panel来实现的form,就是把form窗体打开到panel里,实现左侧是导航,中间是操 ...

  9. winform打开子窗体后,在子窗体中刷新父窗体,或者关闭子窗体刷新父窗体

    winform打开子窗体后,在子窗体中刷新父窗体,或者关闭子窗体刷新父窗体,搜集了几个方法,列举如下: 一 . 所有权法 父窗体,名称为“fuForm”,在父窗体中有个公共刷新方法,也就是窗体数据初始 ...

随机推荐

  1. Linux系统下的程序开发之:命名规范

    2016年12月13日16:19:53 ------------------------------- 不能使用类似驼峰法的命名文件:dingdanOrder.html 这样的命名,会让系统无法找到目 ...

  2. JAVA语言规范-线程和锁章节之同步、等待和通知

    JAVA语言规范:线程和锁 1 同步 java编程语言提供了线程间通信的多种机制.这些方法中最基本的是同步化,此方法是使用监视器实现的.JAVA中每个对象与一个监视器相关联,一个线程可以加锁和解锁监视 ...

  3. YII2生成增删改查

    下载完成后在basic/db.php配置数据库参数. 1.配置虚拟主机后进入YII入口文件 index.php 进行get传值 ?r=gii ,进入创建界面 2.点击 Model Generator下 ...

  4. thinkphp 后台权限列表

    核心代码: // 检测用户权限权限 public function admin_priv($action){ $action_list = session('user.action_list'); i ...

  5. [转] 64位windows下添加postgreSQL odbc数据源

    系统环境:windows7 64位 postgreSQL9.0(64bit)   ps:安装postgreSQL时确定安装了odbc驱动.   问题:点击“开始->控制面板->管理工具-& ...

  6. 探索ASP.NET MVC框架之控制器的查找与激活机制

    引言 前面一篇博文我们介绍了MVC框架的路由机制,我们知道一个URL请求如何从ASP.NET处理管线到达了IHttpHandler实例(MvcHandler).今天我们从MvcHandler来进行下一 ...

  7. Spring实现初始化和销毁bean之前进行的操作,三种方式

    关于在spring  容器初始化 bean 和销毁前所做的操作定义方式有三种: 第一种:通过@PostConstruct 和 @PreDestroy 方法 实现初始化和销毁bean之前进行的操作 第二 ...

  8. 【荐】MongoDB基本命令大全

    DB Shell数据操作 shell命令操作语法和JavaScript很类似,其实控制台底层的查询语句都是用JavaScript脚本完成操作的. #数据库 操作 1.Help查看命令提示 > h ...

  9. poj 1192

    此题亦一眼看出算法,一次AC. 没什么好讲的,就是一个普通的树形动规. 用dp[n][0]表示n号顶点不取时的最大值,dp[n][1]表示n号顶点取时的最大值. dp[n][0]=max{dp[x][ ...

  10. 2016 GitHub章鱼猫观察报告之开源统计

    导读 GitHub 又发布了一年一度的章鱼猫观察报告.在这个报告中,分别对开源和社区做了一些有趣的统计,现将其中一些有趣的数据和趋势撷取出来分享给大家.完整的报告请移步Github. GitHub 上 ...