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. windows 7 docker oralce安装和使用

    7. oracle数据库的安装 7.1 下载镜像 查询:Docker search Oracle 下载: docker pull wnameless/oracle-xe-11g 如果不能下载,有可能是 ...

  2. C++ GC

    http://www.codeproject.com/Articles/912/A-garbage-collection-framework-for-C http://www.codeproject. ...

  3. Java类中各种静态变量的加载顺序的学习

    最近在补<thinking in java>...有一节提到了加载类需要做的一些准备...我照着书本敲了一下代码...同时稍微修改了一下书本上的代码.... package charpte ...

  4. 带有“非简单参数”的函数为什么不能包含 "use strict" 指令

    非简单参数就是 ES6 里新加的参数语法,包括:1.默认参数值.2.剩余参数.3.参数解构.本文接下来要讲的就是 ES7 为什么禁止在使用了非简单参数的函数里使用 "use strict&q ...

  5. undefined method `environment' for nil:NilClass when importing Bootstrap into rails

    今天做项目时往Gemfile里加了各gem, 然后bundle update了一下, 然后悲剧了,出现了undefined method `environment' for nil:NilClass ...

  6. C和指针 第五章 位数组

    5.4的习题:编写一组函数,实现维数组,函数原型如下: //指定位设置为1void set_bit(char bit_array[], unsigned bit_number); //指定位清零 vo ...

  7. HTML5CSS3特效-上下跳动的小球-遁地龙卷风

    (-1)写在前面 我用的是chrome49,这个idea是我在stackoverflow上回答问题时看到了,多谢这位同行,加深了我对很多技术点的理解,最近刚到北京,忙碌了一两天,在后续的日子里,会被安 ...

  8. Postman 发送http请求工具

    http://donglegend.com/2016/10/28/Postman/ Postman 发现一款发送Web API & HTTP 请求的工具,没错,就是Postman.推荐给大家, ...

  9. [codevs1105][COJ0183][NOIP2005]过河

    [codevs1105][COJ0183][NOIP2005]过河 试题描述 在河上有一座独木桥,一只青蛙想沿着独木桥从河的一侧跳到另一侧.在桥上有一些石子,青蛙很讨厌踩在这些石子上.由于桥的长度和青 ...

  10. sdcms标签

    模板防盗:<%if not in_sdcms then response.write("template load fail"):response.end() end if% ...