Note that there are some explanatory texts on larger screens.

plurals
  1. POC# - Update textbox on forms created in code
    primarykey
    data
    text
    <p>I have a main form called mainForm - this runs my entire app. In this form I create other forms like this:</p> <pre><code>...... ...... Form[] formMessage = new Form[10]; int formNumber = 0; System.Windows.Forms.Button btnCancel; System.Windows.Forms.Button btnClose; System.Windows.Forms.Label lblTimer; System.Windows.Forms.Button btnOK; System.Windows.Forms.Panel panel1; System.Windows.Forms.Label lblMessage; System.Windows.Forms.PictureBox pictureBox1; System.Windows.Forms.Label lblTitle; ...... ...... public void CreateForm(Form form2) { this.btnCancel = new System.Windows.Forms.Button(); this.btnClose = new System.Windows.Forms.Button(); this.lblTimer = new System.Windows.Forms.Label(); this.btnOK = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); this.lblMessage = new System.Windows.Forms.Label(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.lblTitle = new System.Windows.Forms.Label(); // ........ // // lblTimer // this.lblTimer.AutoSize = true; this.lblTimer.BackColor = System.Drawing.Color.Transparent; this.lblTimer.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblTimer.Location = new System.Drawing.Point(9, 120); this.lblTimer.Name = "lblTimer"; this.lblTimer.Size = new System.Drawing.Size(0, 16); this.lblTimer.Visible = Show_Timer; this.lblTimer.TabIndex = 4; form2.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); form2.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; form2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); form2.ClientSize = new System.Drawing.Size(400, 142); form2.ControlBox = false; form2.Controls.Add(this.pictureBox1); form2.Controls.Add(this.panel1); form2.Controls.Add(this.btnOK); form2.Controls.Add(this.lblTimer); form2.Controls.Add(this.btnCancel); form2.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; form2.Opacity = 0.98; form2.ShowInTaskbar = false; form2.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; form2.Tag = formNumber; form2.Paint += new System.Windows.Forms.PaintEventHandler(this.MyMessageBox_Paint); } private void FNeventTrigger(System.Object sender, System.EventArgs e) { formMessage[formNumber] = new Form(); CreateForm(formMessage[formNumber]); formMessage[formNumber].Show(); formNumber++; if (formNumber == 10) formNumber = 0; } public void lbl_timer_UpdateText() { this.lblTimer.Text = newText } </code></pre> <p>I use the FNeventRigger to create my form, and I can have upto 10 of them open at each given time - I use this for showing count down timers.</p> <p>The problem I have is how do I show the count down timer of each form? If I use : this.lblTimer.Text = newText, then only the newest form that was opened displays the correct timer.... the other forms lblTimer.Text stop functioning.</p> <p>Is there a way to address all the lblTimer.Text on all forms opened on the array?</p> <p>Thanks,</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload