How can i update in realtime textbox3 in Form1 when other Form is in closing event ?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; private <span style="color:Blue; void Options_Menu_FormClosing(<span style="color:Blue; object sender, FormClosingEventArgs e)
{

}
[/code]

I have in this Options_Menu a variable:

<div style="color:Black;background-color:White; <pre>
f1 = <span style="color:Blue; new Form1();

f1._outputDir = Options_DB.get_outputDir();
textBox3.Text = f1._outputDir;
[/code]
<br/>
Im updating textbox3 on the Options_Menu form and its ok and i also updating textbox3 on Form1 in the constructor with the Options_DB.get_outputDir();

But i want when im in the Options_Menu and im changing there the directory it will show the change also in Form1 in realtime not only only when i close the Options_Menu form and not only when im running the program again but as im changing the directory
in the Options_Menu form it will also change it in texbox3 in Form1.

This is the code of the Options_Menu:

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; using System;
<span style="color:Blue; using System.Collections.Generic;
<span style="color:Blue; using System.ComponentModel;
<span style="color:Blue; using System.Data;
<span style="color:Blue; using System.Drawing;
<span style="color:Blue; using System.Linq;
<span style="color:Blue; using System.Text;
<span style="color:Blue; using System.Windows.Forms;
<span style="color:Blue; using System.IO;
<span style="color:Blue; using WindowsFormsApplication1;
<span style="color:Blue; using DannyGeneral;

<span style="color:Blue; namespace Extracting_Frames
{
<span style="color:Blue; public <span style="color:Blue; partial <span style="color:Blue; class Options_Menu : Form
{
Form1 f1;

<span style="color:Blue; public Options_Menu()
{
InitializeComponent();
f1 = <span style="color:Blue; new Form1();

f1._outputDir = Options_DB.get_outputDir();
textBox3.Text = f1._outputDir;

<span style="color:Green; //f1._outputDir = Options_DB.get_outputDir();
}

<span style="color:Blue; private <span style="color:Blue; void button8_Click(<span style="color:Blue; object sender, EventArgs e)
{

}

<span style="color:Blue; private <span style="color:Blue; void View_Log_File_Click(<span style="color:Blue; object sender, EventArgs e)
{

}

<span style="color:Blue; private <span style="color:Blue; void button2_Click(<span style="color:Blue; object sender, EventArgs e)
{
FolderBrowserDialog fb;
fb = <span style="color:Blue; new FolderBrowserDialog();
fb.Description = <span style="color:#A31515; "Select Output Directorry";
<span style="color:Blue; if (fb.ShowDialog() == DialogResult.OK)
{
<span style="color:Blue; string message = <span style="color:#A31515; "Are you sure you want to save the image to this location ?";
<span style="color:Blue; string caption = <span style="color:#A31515; "Operation cancelled";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result;
result = MessageBox.Show(message, caption, buttons);

<span style="color:Blue; if (result == System.Windows.Forms.DialogResult.Yes)
{
f1._outputDir = fb.SelectedPath;
textBox3.Text = f1._outputDir;
Options_DB.set_outputdirectory(f1._outputDir);

}
}
}

<span style="color:Blue; private <span style="color:Blue; void Options_Menu_FormClosing(<span style="color:Blue; object sender, FormClosingEventArgs e)
{

}
}
}

[/code]
<br/>
Designer:

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; namespace Extracting_Frames
{
<span style="color:Blue; partial <span style="color:Blue; class Options_Menu
{
<span style="color:Gray; /// <span style="color:Gray; <summary>
<span style="color:Gray; ///<span style="color:Green; Required designer variable.
<span style="color:Gray; /// <span style="color:Gray; </summary>
<span style="color:Blue; private System.ComponentModel.IContainer components = <span style="color:Blue; null;

<span style="color:Gray; /// <span style="color:Gray; <summary>
<span style="color:Gray; ///<span style="color:Green; Clean up any resources being used.
<span style="color:Gray; /// <span style="color:Gray; </summary>
<span style="color:Gray; /// <span style="color:Gray; <param name="disposing <span style="color:Green; true if managed resources should be disposed; otherwise, false.</param>
<span style="color:Blue; protected <span style="color:Blue; override <span style="color:Blue; void Dispose(<span style="color:Blue; bool disposing)
{
<span style="color:Blue; if (disposing && (components != <span style="color:Blue; null))
{
components.Dispose();
}
<span style="color:Blue; base.Dispose(disposing);
}

<span style="color:Blue; #region Windows Form Designer generated code

<span style="color:Gray; /// <span style="color:Gray; <summary>
<span style="color:Gray; ///<span style="color:Green; Required method for Designer support - do not modify
<span style="color:Gray; ///<span style="color:Green; the contents of this method with the code editor.
<span style="color:Gray; /// <span style="color:Gray; </summary>
<span style="color:Blue; private <span style="color:Blue; void InitializeComponent()
{
<span style="color:Blue; this.groupBox1 = <span style="color:Blue; new System.Windows.Forms.GroupBox();
<span style="color:Blue; this.label5 = <span style="color:Blue; new System.Windows.Forms.Label();
<span style="color:Blue; this.button2 = <span style="color:Blue; new System.Windows.Forms.Button();
<span style="color:Blue; this.textBox3 = <span style="color:Blue; new System.Windows.Forms.TextBox();
<span style="color:Blue; this.label3 = <span style="color:Blue; new System.Windows.Forms.Label();
<span style="color:Blue; this.View_Log_File = <span style="color:Blue; new System.Windows.Forms.Button();
<span style="color:Blue; this.button8 = <span style="color:Blue; new System.Windows.Forms.Button();
<span style="color:Blue; this.groupBox2 = <span style="color:Blue; new System.Windows.Forms.GroupBox();
<span style="color:Blue; this.groupBox1.SuspendLayout();
<span style="color:Blue; this.SuspendLayout();
<span style="color:Green; //
<span style="color:Green; // groupBox1
<span style="color:Green; //
<span style="color:Blue; this.groupBox1.Controls.Add(<span style="color:Blue; this.label5);
<span style="color:Blue; this.groupBox1.Controls.Add(<span style="color:Blue; this.button2);
<span style="color:Blue; this.groupBox1.Controls.Add(<span style="color:Blue; this.textBox3);
<span style="color:Blue; this.groupBox1.Controls.Add(<span style="color:Blue; this.label3);
<span style="color:Blue; this.groupBox1.Controls.Add(<span style="color:Blue; this.View_Log_File);
<span style="color:Blue; this.groupBox1.Controls.Add(<span style="color:Blue; this.button8);
<span style="color:Blue; this.groupBox1.Controls.Add(<span style="color:Blue; this.groupBox2);
<span style="color:Blue; this.groupBox1.Location = <span style="color:Blue; new System.Drawing.Point(12, 17);
<span style="color:Blue; this.groupBox1.Name = <span style="color:#A31515; "groupBox1";
<span style="color:Blue; this.groupBox1.Size = <span style="color:Blue; new System.Drawing.Size(760, 528);
<span style="color:Blue; this.groupBox1.TabIndex = 2;
<span style="color:Blue; this.groupBox1.TabStop = <span style="color:Blue; false;
<span style="color:Green; //
<span style="color:Green; // label5
<span style="color:Green; //
<span style="color:Blue; this.label5.AutoSize = <span style="color:Blue; true;
<span style="color:Blue; this.label5.ForeColor = System.Drawing.Color.Red;
<span style="color:Blue; this.label5.Location = <span style="color:Blue; new System.Drawing.Point(30, 167);
<span style="color:Blue; this.label5.Name = <span style="color:#A31515; "label5";
<span style="color:Blue; this.label5.Size = <span style="color:Blue; new System.Drawing.Size(138, 13);
<span style="color:Blue; this.label5.TabIndex = 78;
<span style="color:Blue; this.label5.Text = <span style="color:#A31515; "Change the output directory";
<span style="color:Green; //
<span style="color:Green; // button2
<span style="color:Green; //
<span style="color:Blue; this.button2.Font = <span style="color:Blue; new System.Drawing.Font(<span style="color:#A31515; "Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((<span style="color:Blue; byte)(177)));
<span style="color:Blue; this.button2.Location = <span style="color:Blue; new System.Drawing.Point(394, 181);
<span style="color:Blue; this.button2.Name = <span style="color:#A31515; "button2";
<span style="color:Blue; this.button2.Size = <span style="color:Blue; new System.Drawing.Size(55, 23);
<span style="color:Blue; this.button2.TabIndex = 77;
<span style="color:Blue; this.button2.Text = <span style="color:#A31515; "Set Dir";
<span style="color:Blue; this.button2.UseVisualStyleBackColor = <span style="color:Blue; true;
<span style="color:Blue; this.button2.Click += <span style="color:Blue; new System.EventHandler(<span style="color:Blue; this.button2_Click);
<span style="color:Green; //
<span style="color:Green; // textBox3
<span style="color:Green; //
<span style="color:Blue; this.textBox3.Enabled = <span style="color:Blue; false;
<span style="color:Blue; this.textBox3.Location = <span style="color:Blue; new System.Drawing.Point(31, 183);
<span style="color:Blue; this.textBox3.Name = <span style="color:#A31515; "textBox3";
<span style="color:Blue; this.textBox3.Size = <span style="color:Blue; new System.Drawing.Size(357, 20);
<span style="color:Blue; this.textBox3.TabIndex = 76;
<span style="color:Green; //
<span style="color:Green; // label3
<span style="color:Green; //
<span style="color:Blue; this.label3.AutoSize = <span style="color:Blue; true;
<span style="color:Blue; this.label3.ForeColor = System.Drawing.Color.DarkGreen;
<span style="color:Blue; this.label3.Location = <span style="color:Blue; new System.Drawing.Point(29, 188);
<span style="color:Blue; this.label3.Name = <span style="color:#A31515; "label3";
<span style="color:Blue; this.label3.Size = <span style="color:Blue; new System.Drawing.Size(0, 13);
<span style="color:Blue; this.label3.TabIndex = 74;
<span style="color:Green; //
<span style="color:Green; // View_Log_File
<span style="color:Green; //
<span style="color:Blue; this.View_Log_File.Location = <span style="color:Blue; new System.Drawing.Point(29, 19);
<span style="color:Blue; this.View_Log_File.Name = <span style="color:#A31515; "View_Log_File";
<span style="color:Blue; this.View_Log_File.Size = <span style="color:Blue; new System.Drawing.Size(165, 23);
<span style="color:Blue; this.View_Log_File.TabIndex = 73;
<span style="color:Blue; this.View_Log_File.Text = <span style="color:#A31515; "View Log File";
<span style="color:Blue; this.View_Log_File.UseVisualStyleBackColor = <span style="color:Blue; true;
<span style="color:Blue; this.View_Log_File.Click += <span style="color:Blue; new System.EventHandler(<span style="color:Blue; this.View_Log_File_Click);
<span style="color:Green; //
<span style="color:Green; // button8
<span style="color:Green; //
<span style="color:Blue; this.button8.Location = <span style="color:Blue; new System.Drawing.Point(29, 58);
<span style="color:Blue; this.button8.Name = <span style="color:#A31515; "button8";
<span style="color:Blue; this.button8.Size = <span style="color:Blue; new System.Drawing.Size(165, 23);
<span style="color:Blue; this.button8.TabIndex = 71;
<span style="color:Blue; this.button8.Text = <span style="color:#A31515; "Browse Program Directories";
<span style="color:Blue; this.button8.UseVisualStyleBackColor = <span style="color:Blue; true;
<span style="color:Blue; this.button8.Click += <span style="color:Blue; new System.EventHandler(<span style="color:Blue; this.button8_Click);
<span style="color:Green; //
<span style="color:Green; // groupBox2
<span style="color:Green; //
<span style="color:Blue; this.groupBox2.Location = <span style="color:Blue; new System.Drawing.Point(29, 152);
<span style="color:Blue; this.groupBox2.Name = <span style="color:#A31515; "groupBox2";
<span style="color:Blue; this.groupBox2.Size = <span style="color:Blue; new System.Drawing.Size(420, 79);
<span style="color:Blue; this.groupBox2.TabIndex = 83;
<span style="color:Blue; this.groupBox2.TabStop = <span style="color:Blue; false;
<span style="color:Green; //
<span style="color:Green; // Options_Menu
<span style="color:Green; //
<span style="color:Blue; this.AutoScaleDimensions = <span style="color:Blue; new System.Drawing.SizeF(6F, 13F);
<span style="color:Blue; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
<span style="color:Blue; this.ClientSize = <span style="color:Blue; new System.Drawing.Size(784, 562);
<span style="color:Blue; this.Controls.Add(<span style="color:Blue; this.groupBox1);
<span style="color:Blue; this.Name = <span style="color:#A31515; "Options_Menu";
<span style="color:Blue; this.Text = <span style="color:#A31515; "Options_Menu";
<span style="color:Blue; this.FormClosing += <span style="color:Blue; new System.Windows.Forms.FormClosingEventHandler(<span style="color:Blue; this.Options_Menu_FormClosing);
<span style="color:Blue; this.groupBox1.ResumeLayout(<span style="color:Blue; false);
<span style="color:Blue; this.groupBox1.PerformLayout();
<span style="color:Blue; this.ResumeLayout(<span style="color:Blue; false);

}

<span style="color:Blue; #endregion

<span style="color:Blue; private System.Windows.Forms.GroupBox groupBox1;
<span style="color:Blue; private System.Windows.Forms.Label label5;
<span style="color:Blue; private System.Windows.Forms.Button button2;
<span style="color:Blue; private System.Windows.Forms.TextBox textBox3;
<span style="color:Blue; private System.Windows.Forms.Label label3;
<span style="color:Blue; private System.Windows.Forms.Button View_Log_File;
<span style="color:Blue; private System.Windows.Forms.Button button8;
<span style="color:Blue; private System.Windows.Forms.GroupBox groupBox2;
}
}
[/code]
<br/>
<br/>
<hr class="sig danieli

View the full article
 
Back
Top