私は2つのウィンドウフォームをメインとし、プロジェクトに追加するものがあります。第2の書式は、いくつかの内容buttons, rich text boxes, label
とe.t.cを持っています。私はこのコードを使用して、ボタンクリックを使用して、メインフォームから、第二のウィンドウを開くようにしたい:メインフォームから既に作成されたフォームを開く
private void button_Click(object sender, EventArgs e)
{
Exam frm= new Exam();
frm.ShowDialog();
}
プログラムは、私はすでに第二のウィンドウに追加した新しいウィンドウが、ドキュメントがありませんが、飛び出したより。誰かに助けてください:)
これはExam.Designer.cs
ファイルです:
namespace Legal_Hunt {
partial class Exam
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.richTextBox2 = new System.Windows.Forms.RichTextBox();
this.richTextBox3 = new System.Windows.Forms.RichTextBox();
this.richTextBox4 = new System.Windows.Forms.RichTextBox();
this.richTextBox5 = new System.Windows.Forms.RichTextBox();
this.button5 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// richTextBox1
//
this.richTextBox1.BackColor = System.Drawing.Color.Salmon;
this.richTextBox1.Font = new System.Drawing.Font("Sylfaen", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.richTextBox1.Location = new System.Drawing.Point(7, 8);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.ReadOnly = true;
this.richTextBox1.Size = new System.Drawing.Size(617, 173);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "";
//
// button1
//
this.button1.Font = new System.Drawing.Font("Sylfaen", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button1.Location = new System.Drawing.Point(7, 188);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(617, 75);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// button2
//
this.button2.Font = new System.Drawing.Font("Sylfaen", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button2.Location = new System.Drawing.Point(7, 269);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(617, 75);
this.button2.TabIndex = 2;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
//
// button3
//
this.button3.Font = new System.Drawing.Font("Sylfaen", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button3.Location = new System.Drawing.Point(7, 350);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(617, 75);
this.button3.TabIndex = 3;
this.button3.Text = "button3";
this.button3.UseVisualStyleBackColor = true;
//
// button4
//
this.button4.Font = new System.Drawing.Font("Sylfaen", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button4.Location = new System.Drawing.Point(7, 431);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(617, 75);
this.button4.TabIndex = 4;
this.button4.Text = "button4";
this.button4.UseVisualStyleBackColor = true;
//
// richTextBox2
//
this.richTextBox2.Location = new System.Drawing.Point(630, 8);
this.richTextBox2.Name = "richTextBox2";
this.richTextBox2.Size = new System.Drawing.Size(170, 173);
this.richTextBox2.TabIndex = 5;
this.richTextBox2.Text = "";
//
// richTextBox3
//
this.richTextBox3.Location = new System.Drawing.Point(631, 188);
this.richTextBox3.Name = "richTextBox3";
this.richTextBox3.Size = new System.Drawing.Size(169, 75);
this.richTextBox3.TabIndex = 6;
this.richTextBox3.Text = "";
//
// richTextBox4
//
this.richTextBox4.Location = new System.Drawing.Point(631, 269);
this.richTextBox4.Name = "richTextBox4";
this.richTextBox4.Size = new System.Drawing.Size(169, 75);
this.richTextBox4.TabIndex = 7;
this.richTextBox4.Text = "";
//
// richTextBox5
//
this.richTextBox5.Location = new System.Drawing.Point(630, 350);
this.richTextBox5.Name = "richTextBox5";
this.richTextBox5.Size = new System.Drawing.Size(170, 75);
this.richTextBox5.TabIndex = 8;
this.richTextBox5.Text = "";
//
// button5
//
this.button5.Font = new System.Drawing.Font("Sylfaen", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button5.Location = new System.Drawing.Point(630, 431);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(169, 75);
this.button5.TabIndex = 9;
this.button5.Text = "დაწყება";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// Exam
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(812, 538);
this.Controls.Add(this.button5);
this.Controls.Add(this.richTextBox5);
this.Controls.Add(this.richTextBox4);
this.Controls.Add(this.richTextBox3);
this.Controls.Add(this.richTextBox2);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.richTextBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(828, 577);
this.MinimumSize = new System.Drawing.Size(828, 577);
this.Name = "Exam";
this.Text = "Exam";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.RichTextBox richTextBox2;
private System.Windows.Forms.RichTextBox richTextBox3;
private System.Windows.Forms.RichTextBox richTextBox4;
private System.Windows.Forms.RichTextBox richTextBox5;
private System.Windows.Forms.Button button5;
} }
と、これはExam.cs
ファイルである。この場合
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Legal_Hunt
{
public partial class Exam : Form
{
public Exam()
{
}
private void button5_Click(object sender, EventArgs e)
{
button5.Text = "მომდევნო";
}
}
を飛び出すときに、第2のフォームが空白ですが、私はExam.cs
を変更したときそのようなファイル:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Legal_Hunt
{
public partial class Exam : Form
{
public Exam()
{
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.richTextBox2 = new System.Windows.Forms.RichTextBox();
this.richTextBox3 = new System.Windows.Forms.RichTextBox();
this.richTextBox4 = new System.Windows.Forms.RichTextBox();
this.richTextBox5 = new System.Windows.Forms.RichTextBox();
this.button5 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// richTextBox1
//
this.richTextBox1.BackColor = System.Drawing.Color.Salmon;
this.richTextBox1.Font = new System.Drawing.Font("Sylfaen", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.richTextBox1.Location = new System.Drawing.Point(7, 8);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.ReadOnly = true;
this.richTextBox1.Size = new System.Drawing.Size(617, 173);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "";
//
// button1
//
this.button1.Font = new System.Drawing.Font("Sylfaen", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button1.Location = new System.Drawing.Point(7, 188);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(617, 75);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// button2
//
this.button2.Font = new System.Drawing.Font("Sylfaen", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button2.Location = new System.Drawing.Point(7, 269);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(617, 75);
this.button2.TabIndex = 2;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
//
// button3
//
this.button3.Font = new System.Drawing.Font("Sylfaen", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button3.Location = new System.Drawing.Point(7, 350);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(617, 75);
this.button3.TabIndex = 3;
this.button3.Text = "button3";
this.button3.UseVisualStyleBackColor = true;
//
// button4
//
this.button4.Font = new System.Drawing.Font("Sylfaen", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button4.Location = new System.Drawing.Point(7, 431);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(617, 75);
this.button4.TabIndex = 4;
this.button4.Text = "button4";
this.button4.UseVisualStyleBackColor = true;
//
// richTextBox2
//
this.richTextBox2.Location = new System.Drawing.Point(630, 8);
this.richTextBox2.Name = "richTextBox2";
this.richTextBox2.Size = new System.Drawing.Size(170, 173);
this.richTextBox2.TabIndex = 5;
this.richTextBox2.Text = "";
//
// richTextBox3
//
this.richTextBox3.Location = new System.Drawing.Point(631, 188);
this.richTextBox3.Name = "richTextBox3";
this.richTextBox3.Size = new System.Drawing.Size(169, 75);
this.richTextBox3.TabIndex = 6;
this.richTextBox3.Text = "";
//
// richTextBox4
//
this.richTextBox4.Location = new System.Drawing.Point(631, 269);
this.richTextBox4.Name = "richTextBox4";
this.richTextBox4.Size = new System.Drawing.Size(169, 75);
this.richTextBox4.TabIndex = 7;
this.richTextBox4.Text = "";
//
// richTextBox5
//
this.richTextBox5.Location = new System.Drawing.Point(630, 350);
this.richTextBox5.Name = "richTextBox5";
this.richTextBox5.Size = new System.Drawing.Size(170, 75);
this.richTextBox5.TabIndex = 8;
this.richTextBox5.Text = "";
//
// button5
//
this.button5.Font = new System.Drawing.Font("Sylfaen", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button5.Location = new System.Drawing.Point(630, 431);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(169, 75);
this.button5.TabIndex = 9;
this.button5.Text = "დაწყება";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// Exam
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(812, 538);
this.Controls.Add(this.button5);
this.Controls.Add(this.richTextBox5);
this.Controls.Add(this.richTextBox4);
this.Controls.Add(this.richTextBox3);
this.Controls.Add(this.richTextBox2);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.richTextBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(828, 577);
this.MinimumSize = new System.Drawing.Size(828, 577);
this.Name = "Exam";
this.Text = "Exam";
this.ResumeLayout(false);
}
private void button5_Click(object sender, EventArgs e)
{
button5.Text = "მომდევნო";
}
}
}
すべてが問題ありません。それはこのようなものでしょうか?
あなたの問題は何か分かりません。あなたは少し良く説明できますか? – Steve
このクリックイベントハンドラは、「Exam」フォームの新しいインスタンスを作成します。コントロールにコンストラクタまたは一部のイベント前のイベントハンドラの内容を入力しない限り、常に空白になります。だから、「既に追加した...コンテンツ」とはどういう意味ですか? – dlatikay
試験フォームには内容がありますが、ポップアウトには含まれていません。 – AlexL