本文整理汇总了C#中System.Windows.Forms.Form.AddOwnedForm方法的典型用法代码示例。如果您正苦于以下问题:C# Form.AddOwnedForm方法的具体用法?C# Form.AddOwnedForm怎么用?C# Form.AddOwnedForm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Form
的用法示例。
在下文中一共展示了Form.AddOwnedForm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowMyOwnedForm
private void ShowMyOwnedForm()
{
// Create an instance of the form to be owned.
Form ownedForm = new Form();
// Set the text of the form to identify it is an owned form.
ownedForm.Text = "Owned Form";
// Add ownedForm to array of owned forms.
this.AddOwnedForm(ownedForm);
// Show the owned form.
ownedForm.Show();
}
示例2: ChildForm
//引入命名空间
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class ChildForm : Form
{
public System.Windows.Forms.Label lblState;
public ChildForm()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.lblState = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// lblState
//
this.lblState.Location = new System.Drawing.Point(26, 24);
this.lblState.Name = "lblState";
this.lblState.Size = new System.Drawing.Size(184, 56);
this.lblState.TabIndex = 2;
//
// ChildForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(236, 104);
this.Controls.Add(this.lblState);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "ChildForm";
this.Text = "ChildForm";
this.ResumeLayout(false);
}
}
public class ParentForm : Form{
private System.Windows.Forms.Button cmdReleaseOwnership;
private System.Windows.Forms.Button cmdAddOwnership;
public ParentForm()
{
InitializeComponent();
frmOwned.Show();
}
private ChildForm frmOwned = new ChildForm();
private void cmdAddOwnership_Click(object sender, System.EventArgs e)
{
this.AddOwnedForm(frmOwned);
frmOwned.lblState.Text = "Owned. Minimize me to see the difference.";
}
private void cmdReleaseOwnership_Click(object sender, System.EventArgs e)
{
this.RemoveOwnedForm(frmOwned);
frmOwned.lblState.Text = "Not owned! Minimize me to see the difference.";
}
private void InitializeComponent()
{
this.cmdReleaseOwnership = new System.Windows.Forms.Button();
this.cmdAddOwnership = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// cmdReleaseOwnership
//
this.cmdReleaseOwnership.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cmdReleaseOwnership.Location = new System.Drawing.Point(150, 197);
this.cmdReleaseOwnership.Name = "cmdReleaseOwnership";
this.cmdReleaseOwnership.Size = new System.Drawing.Size(128, 32);
this.cmdReleaseOwnership.TabIndex = 6;
this.cmdReleaseOwnership.Text = "Remove Ownership";
this.cmdReleaseOwnership.Click += new System.EventHandler(this.cmdReleaseOwnership_Click);
//
// cmdAddOwnership
//
this.cmdAddOwnership.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cmdAddOwnership.Location = new System.Drawing.Point(14, 197);
this.cmdAddOwnership.Name = "cmdAddOwnership";
this.cmdAddOwnership.Size = new System.Drawing.Size(120, 32);
this.cmdAddOwnership.TabIndex = 5;
this.cmdAddOwnership.Text = "Set Ownership";
this.cmdAddOwnership.Click += new System.EventHandler(this.cmdAddOwnership_Click);
//
// ParentForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.cmdReleaseOwnership);
this.Controls.Add(this.cmdAddOwnership);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "ParentForm";
this.Text = "Owner";
// this.Load += new System.EventHandler(this.ParentForm_Load);
this.ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new ParentForm());
}
}