Change Form window ownership : Form Frame Window « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » GUI Windows Form » Form Frame WindowScreenshots 
Change Form window ownership
Change Form window ownership

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(2624);
    this.lblState.Name = "lblState";
    this.lblState.Size = new System.Drawing.Size(18456);
    this.lblState.TabIndex = 2;
    // 
    // ChildForm
    // 
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(236104);
    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(150197);
    this.cmdReleaseOwnership.Name = "cmdReleaseOwnership";
    this.cmdReleaseOwnership.Size = new System.Drawing.Size(12832);
    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(14197);
    this.cmdAddOwnership.Name = "cmdAddOwnership";
    this.cmdAddOwnership.Size = new System.Drawing.Size(12032);
    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(6F13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(292266);
    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());
  }

}


           
       
Related examples in the same category
1.Print out Form size and position related information
2.Use Font from Form to paint string on a form
3.Set ResizeRedraw property
4.Set ClientSize to change the form window size
5.FormStartPosition.CenterScreen
6.Form hideForm hide
7.Create Graphics Object from form window handleCreate Graphics Object from form window handle
8.Center form windowCenter form window
9.Assign Form window default valueAssign Form window default value
10.Change the background and text colors of a form using Color DialogChange the background and text colors of a form using Color Dialog
11.Draw image based on the window sizeDraw image based on the window size
12.Auto scroll form windowAuto scroll form window
13.Set Form window title and center the Form window on the desktopSet Form window title and center the Form window on the desktop
14.Add control to a form windowAdd control to a form window
15.Change Form window backgroundChange Form window background
16.Simplest form code: set window titleSimplest form code: set window title
17.Login fromLogin from
18.makes a new window out of a graphics path that has been traced on this forms spacemakes a new window out of a graphics path that has been traced on this forms space
19.Windows Forms Getting StartedWindows Forms Getting Started
20.A form-based Windows SkeletonA form-based Windows Skeleton
21.Simple formSimple form
22.Add controls to a formAdd controls to a form
23.Form for data inputForm for data input
24.Demonstrates creating a form in a console programDemonstrates creating a form in a console program
25.AutoScrollPosition
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.