Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

fabricioss

Como alterar propridades de MDI child?

Recommended Posts

Pessoal,Estou estudando C#, especificamente resolvendo o exercício abaixo. Gostaria de saber como eu faço para alterar as propriedades font, color e size do textbox da MDI child. Sei fazer isso em forms normais...Alguma sugestão? Estou colando o exercício e as duas classes que eu criei até o momento.Create an MDI text editor. Each child window should contain a multiline TextBox. TheMDI parent should have a Format menu, with submenus to control the size, font and color of the textin the active child window. Each submenu should have at least three options. In addition, the parentshould have a File menu with menu items New (create a new child), Close (close the active child)and Exit (exit the application). The parent should have a Window menu to display a list of the openchild windows and their layout options.using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;namespace Exe_13._7{ /// <summary> /// Summary description for Form1. /// </summary> public class formParent : System.Windows.Forms.Form { private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem fileMenuItem; private System.Windows.Forms.MenuItem newMenuItem; private System.Windows.Forms.MenuItem closeMenuItem; private System.Windows.Forms.MenuItem exitMenuItem; private System.Windows.Forms.MenuItem formatMenuItem; private System.Windows.Forms.MenuItem sizeMenuItem; private System.Windows.Forms.MenuItem fontMenuItem; private System.Windows.Forms.MenuItem colorMenuItem; private System.Windows.Forms.MenuItem windowMenuItem; public System.Windows.Forms.MenuItem eightsizeMenuItem; public System.Windows.Forms.MenuItem twelvesizeMenuItem; private System.Windows.Forms.MenuItem sixteensizeMenuItem; private System.Windows.Forms.MenuItem comicMenuItem; private System.Windows.Forms.MenuItem courierMenuItem; private System.Windows.Forms.MenuItem timesMenuItem; private System.Windows.Forms.MenuItem blackMenuItem; private System.Windows.Forms.MenuItem blueMenuItem; private System.Windows.Forms.MenuItem redMenuItem; private System.Windows.Forms.MenuItem greenMenuItem; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public formParent() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// The main entry point for the application. /// </summary> [sTAThread] static void Main() { Application.Run(new formParent()); } private void newMenuItem_Click(object sender, System.EventArgs e) { formatMenuItem.Enabled = true; windowMenuItem.Enabled = true; formChild child = new formChild(); child.MdiParent = this; // set parent child.Show(); // display child } private void closeMenuItem_Click(object sender, System.EventArgs e) { this.ActiveMdiChild.Close(); if ( this.MdiChildren.Length == 0 ) { formatMenuItem.Enabled = false; windowMenuItem.Enabled = false; } } private void exitMenuItem_Click(object sender, System.EventArgs e) { Application.Exit(); } private void ClearSize() { eightsizeMenuItem.Checked = false; twelvesizeMenuItem.Checked = false; sixteensizeMenuItem.Checked = false; } private void ClearFont() { comicMenuItem.Checked = false; timesMenuItem.Checked = false; courierMenuItem.Checked = false; } private void ClearColor() { blackMenuItem.Checked = false; blueMenuItem.Checked = false; greenMenuItem.Checked = false; redMenuItem.Checked = false; } private void eightsizeMenuItem_Click(object sender, System.EventArgs e) { ClearSize(); childTextBox.Font = new Font( formChild.childTextBox.Font.Name, 18 ); } }}using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;namespace Exe_13._7{ /// <summary> /// Summary description for childForm. /// </summary> public class formChild : System.Windows.Forms.Form { public System.Windows.Forms.TextBox childTextBox; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public formChild() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(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.childTextBox = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // childTextBox // this.childTextBox.Location = new System.Drawing.Point(16, 16); this.childTextBox.Multiline = true; this.childTextBox.Name = "childTextBox"; this.childTextBox.Size = new System.Drawing.Size(256, 240); this.childTextBox.TabIndex = 0; this.childTextBox.Text = ""; // // formChild // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.Add(this.childTextBox); this.Name = "formChild"; this.Text = "Child Window"; this.ResumeLayout(false); } #endregion }}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pessoal,Consegui! foi só usar as duas linhas abaixo.formChild objfrmMChild = (formChild)this.ActiveMdiChild; objfrmMChild.childTextBox.Font = new Font( objfrmMChild.childTextBox.Font.Name, 18 );

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.