Webbrowser doesn't show scrollbars and can I add touch? - c#

In WM6.5 a have a simple form with a webbrowser control. I open a local file and fill this page data to the document.text
1.
On some phones you see the page but no scrollbar?
2.
On my phone and in the simulators I have a scrollbar. If you put your finger on the screen and move vertically you only highlight the text. What I would like is the page to scroll down/up with this touch.
Is there a trick for this? Below is my init and the filling of the html.
public partial class FormLicense : Form
{
bool _CanClose = false;
private const string _html =
"<html><body><br><div style='top:20px;left:50px;border:solid 1px red'><a href='http://www.cnn.com'>CNN</a></div><br><font size='14'>xx</font><a href='http://stackoverflow.com'>stackoverflow</a></body></html>";
public FormLicense()
{
InitializeComponent();
this.Load += new System.EventHandler(this.FormLicense_Load);
this.Closed += new System.EventHandler(this.FormLicense_Closed);
this.Closing += new System.ComponentModel.CancelEventHandler(this.FormLicense_Closing);
this.SuspendLayout();
this.menu1L.Text = "I Accept";
this.menu1R.Text = "Don't Accept";
this.Text = "License";
using (StreamReader sr = new StreamReader(GlobalLicense.FileName, System.Text.Encoding.Default))
{
webBrowser1.DocumentText = sr.ReadToEnd();
}
.....
....
...
..
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menu1L = new System.Windows.Forms.MenuItem();
this.menu1R = new System.Windows.Forms.MenuItem();
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
this.SuspendLayout();
//
// mainMenu1
//
this.mainMenu1.MenuItems.Add(this.menu1L);
this.mainMenu1.MenuItems.Add(this.menu1R);
//
// menu1L
//
this.menu1L.Text = "1L";
this.menu1L.Click += new System.EventHandler(this.menu1L_Click);
//
// menu1R
//
this.menu1R.Text = "1R";
this.menu1R.Click += new System.EventHandler(this.menu1R_Click);
//
// webBrowser1
//
this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
this.webBrowser1.Location = new System.Drawing.Point(0, 0);
this.webBrowser1.Name = "webBrowser1";
this.webBrowser1.ScriptErrorsSuppressed = true;
this.webBrowser1.Size = new System.Drawing.Size(240, 268);
//
// FormLicense
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScroll = true;
this.AutoScrollMargin = new System.Drawing.Size(10, 10);
this.ClientSize = new System.Drawing.Size(240, 268);
this.Controls.Add(this.webBrowser1);
this.Menu = this.mainMenu1;
this.Name = "FormLicense";
this.Text = "FormLicense";
this.ResumeLayout(false);

The scrollbar problem is a bug:
Link

Related

Why does Visual Studio 2017 keep changing my public static statements to "public" after I change any aspect of any object on a form in C#

I've posted my code. Every single time I change anything on my this form in my Windows Forms App in C#, it changes my "public static" changes at the end to just "public" and then it adds "this." to every single reference to them. My code seems to run fine after I edit it again, but this is really annoying. I just wanted to make sure I'm not missing something or taking a poor approach to this.
The reason I am using public static statements is because I am modifying some Textboxes and a DataGridView object on my main form from other forms - i.e. looking up customer info from a database in one form and then entering the data on the main form to write up an order, and taking shopping cart information from a WebBrowser control on one form and putting it into a DataGridView object on another form. If this isn't how to accomplish populating forms from another form please tell me how and be as specific as possible as I am quite new to C#. Sorry if I've posted too much code - this is almost everything from my form1.cs file and I didn't know what (if anything) that I have here is causing the problem. The relevant "public static" statements are at the end.
(AFTER I WROTE THIS - I looked up another thread where someone said that forms are supposed to be a "specific instantiation" and that is why the developer environment keeps taking out the "static"). That being the case... HELP!! I do not understand how to change the values on one form from another form and I absolutely need to do so. - this code works, but I guess it's bad practice? - Completely lost and need very specific instructions to make this work)
Thanks in advance!!!
namespace WindowsFormsApp1
{
public partial class frmMain
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.cmdSendEmail = new System.Windows.Forms.Button();
this.cmdExit = new System.Windows.Forms.Button();
this.cmdLookup = new System.Windows.Forms.Button();
this.txtTransactionNumber = new System.Windows.Forms.TextBox();
this.cmdEdit = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.cmdBrowse = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.cmdCustomer = new System.Windows.Forms.Button();
this.txtNotes = new System.Windows.Forms.TextBox();
txtZip = new System.Windows.Forms.TextBox();
txtCountry = new System.Windows.Forms.TextBox();
txtState = new System.Windows.Forms.TextBox();
txtCity = new System.Windows.Forms.TextBox();
txtAddress = new System.Windows.Forms.TextBox();
txtName = new System.Windows.Forms.TextBox();
txtPayPalEmail = new System.Windows.Forms.TextBox();
txtEmail = new System.Windows.Forms.TextBox();
txtPhone = new System.Windows.Forms.TextBox();
txtLast = new System.Windows.Forms.TextBox();
txtFirst = new System.Windows.Forms.TextBox();
grdOrderItems = new System.Windows.Forms.DataGridView();
this.Qty = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Description = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.UnitPrice = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ExtPrice = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.SCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Options1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Options2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.lblSubTotal = new System.Windows.Forms.Label();
this.lblTotal = new System.Windows.Forms.Label();
this.txtTax = new System.Windows.Forms.TextBox();
this.txtShipping = new System.Windows.Forms.TextBox();
this.txtShippingMethod = new System.Windows.Forms.TextBox();
this.cmdTaxLookup = new System.Windows.Forms.Button();
this.lstShipping = new System.Windows.Forms.ListBox();
this.cmdBrowser = new System.Windows.Forms.Button();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.cmdSendRequest = new System.Windows.Forms.Button();
this.cmdClear = new System.Windows.Forms.Button();
this.cmdSave = new System.Windows.Forms.Button();
this.cmdPrint = new System.Windows.Forms.Button();
this.cmdSavePrintEmail = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(grdOrderItems)).BeginInit();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.SuspendLayout();
//
// cmdLookup
//
this.cmdLookup.Location = new System.Drawing.Point(88, 15);
this.cmdLookup.Name = "cmdLookup";
this.cmdLookup.Size = new System.Drawing.Size(197, 33);
this.cmdLookup.TabIndex = 3;
this.cmdLookup.Text = "Look up order to attach request to";
this.cmdLookup.UseVisualStyleBackColor = true;
//
// txtTransactionNumber
//
this.txtTransactionNumber.Location = new System.Drawing.Point(91, 57);
this.txtTransactionNumber.Name = "txtTransactionNumber";
this.txtTransactionNumber.Size = new System.Drawing.Size(158, 20);
this.txtTransactionNumber.TabIndex = 5;
//
// cmdEdit
//
this.cmdEdit.Location = new System.Drawing.Point(260, 57);
this.cmdEdit.Name = "cmdEdit";
this.cmdEdit.Size = new System.Drawing.Size(87, 30);
this.cmdEdit.TabIndex = 6;
this.cmdEdit.Text = "Edit";
this.cmdEdit.UseVisualStyleBackColor = true;
//
//
// groupBox1
//
this.groupBox1.Location = new System.Drawing.Point(438, 125);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(345, 56);
this.groupBox1.TabIndex = 10;
this.groupBox1.TabStop = false;
//
// cmdBrowse
//
this.cmdBrowse.Location = new System.Drawing.Point(14, 139);
this.cmdBrowse.Name = "cmdBrowse";
this.cmdBrowse.Size = new System.Drawing.Size(220, 22);
this.cmdBrowse.TabIndex = 11;
this.cmdBrowse.Text = "Browse Unpaid Payment Requests";
this.cmdBrowse.UseVisualStyleBackColor = true;
//
// groupBox2
//
this.groupBox2.BackColor = System.Drawing.Color.WhiteSmoke;
this.groupBox2.Controls.Add(this.cmdCustomer);
this.groupBox2.Controls.Add(this.txtNotes);
this.groupBox2.Controls.Add(txtZip);
this.groupBox2.Controls.Add(txtCountry);
this.groupBox2.Controls.Add(txtState);
this.groupBox2.Controls.Add(txtCity);
this.groupBox2.Controls.Add(txtAddress);
this.groupBox2.Controls.Add(txtName);
this.groupBox2.Controls.Add(txtPayPalEmail);
this.groupBox2.Controls.Add(txtEmail);
this.groupBox2.Controls.Add(txtPhone);
this.groupBox2.Controls.Add(txtLast);
this.groupBox2.Controls.Add(txtFirst);
this.groupBox2.Location = new System.Drawing.Point(14, 168);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(749, 264);
this.groupBox2.TabIndex = 12;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Customer Information";
this.groupBox2.Enter += new System.EventHandler(this.groupBox2_Enter);
//
// label21
//
this.label21.AutoSize = true;
this.label21.Location = new System.Drawing.Point(186, 215);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(25, 13);
this.label21.TabIndex = 24;
this.label21.Text = "Zip:";
//
// cmdCustomer
//
this.cmdCustomer.Location = new System.Drawing.Point(657, 136);
this.cmdCustomer.Name = "cmdCustomer";
this.cmdCustomer.Size = new System.Drawing.Size(86, 69);
this.cmdCustomer.TabIndex = 23;
this.cmdCustomer.Text = "Load Customer Info from Prior Order";
this.cmdCustomer.UseVisualStyleBackColor = true;
this.cmdCustomer.Click += new System.EventHandler(this.cmdCustomer_Click);
//
// txtNotes
//
this.txtNotes.AcceptsReturn = true;
this.txtNotes.Location = new System.Drawing.Point(404, 136);
this.txtNotes.Multiline = true;
this.txtNotes.Name = "txtNotes";
this.txtNotes.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtNotes.Size = new System.Drawing.Size(247, 122);
this.txtNotes.TabIndex = 19;
//
// txtZip
//
txtZip.Location = new System.Drawing.Point(211, 212);
txtZip.Name = "txtZip";
txtZip.Size = new System.Drawing.Size(99, 20);
txtZip.TabIndex = 25;
txtZip.TextChanged += new System.EventHandler(this.txtZip_TextChanged);
//
// txtCountry
//
txtCountry.Location = new System.Drawing.Point(72, 237);
txtCountry.Name = "txtCountry";
txtCountry.Size = new System.Drawing.Size(238, 20);
txtCountry.TabIndex = 22;
txtCountry.TextChanged += new System.EventHandler(this.txtCountry_TextChanged);
//
// txtState
//
txtState.Location = new System.Drawing.Point(72, 210);
txtState.Name = "txtState";
txtState.Size = new System.Drawing.Size(108, 20);
txtState.TabIndex = 21;
txtState.TextChanged += new System.EventHandler(this.txtState_TextChanged);
//
// txtCity
//
txtCity.Location = new System.Drawing.Point(72, 185);
txtCity.Name = "txtCity";
txtCity.Size = new System.Drawing.Size(238, 20);
txtCity.TabIndex = 20;
txtCity.TextChanged += new System.EventHandler(this.txtCity_TextChanged);
//
// txtAddress
//
txtAddress.AcceptsReturn = true;
txtAddress.Location = new System.Drawing.Point(72, 92);
txtAddress.Multiline = true;
txtAddress.Name = "txtAddress";
txtAddress.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
txtAddress.Size = new System.Drawing.Size(236, 87);
txtAddress.TabIndex = 18;
txtAddress.TextChanged += new System.EventHandler(this.txtAddress_TextChanged);
//
// txtName
//
txtName.Location = new System.Drawing.Point(72, 68);
txtName.Name = "txtName";
txtName.Size = new System.Drawing.Size(238, 20);
txtName.TabIndex = 17;
txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged);
//
// txtPayPalEmail
//
txtPayPalEmail.Location = new System.Drawing.Point(405, 98);
txtPayPalEmail.Name = "txtPayPalEmail";
txtPayPalEmail.Size = new System.Drawing.Size(203, 20);
txtPayPalEmail.TabIndex = 16;
//
// txtEmail
//
txtEmail.Location = new System.Drawing.Point(404, 65);
txtEmail.Name = "txtEmail";
txtEmail.Size = new System.Drawing.Size(204, 20);
txtEmail.TabIndex = 15;
//
// txtPhone
//
txtPhone.Location = new System.Drawing.Point(405, 39);
txtPhone.Name = "txtPhone";
txtPhone.Size = new System.Drawing.Size(203, 20);
txtPhone.TabIndex = 14;
txtPhone.TextChanged += new System.EventHandler(this.txtPhone_TextChanged);
//
// txtLast
//
txtLast.Location = new System.Drawing.Point(189, 39);
txtLast.Name = "txtLast";
txtLast.Size = new System.Drawing.Size(121, 20);
txtLast.TabIndex = 13;
txtLast.TextChanged += new System.EventHandler(this.txtLast_TextChanged);
//
// txtFirst
//
txtFirst.Location = new System.Drawing.Point(72, 39);
txtFirst.Name = "txtFirst";
txtFirst.Size = new System.Drawing.Size(84, 20);
txtFirst.TabIndex = 12;
txtFirst.TextChanged += new System.EventHandler(this.txtFirst_TextChanged);
// grdOrderItems
//
grdOrderItems.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
grdOrderItems.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
grdOrderItems.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Qty,
this.Description,
this.UnitPrice,
this.ExtPrice,
this.SCode,
this.Options1,
this.Options2});
grdOrderItems.Location = new System.Drawing.Point(10, 19);
grdOrderItems.Name = "grdOrderItems";
grdOrderItems.Size = new System.Drawing.Size(732, 81);
grdOrderItems.TabIndex = 0;
grdOrderItems.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(grdOrderItems_CellValueChanged);
grdOrderItems.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.grdOrderItems_RowsAdded);
//
// Qty
//
this.Qty.HeaderText = "Qty";
this.Qty.Name = "Qty";
this.Qty.Width = 48;
//
// Description
//
this.Description.HeaderText = "Description";
this.Description.Name = "Description";
this.Description.Width = 85;
//
// UnitPrice
//
this.UnitPrice.HeaderText = "Unit Price";
this.UnitPrice.Name = "UnitPrice";
this.UnitPrice.Width = 78;
//
// ExtPrice
//
this.ExtPrice.HeaderText = "Ext. Price3";
this.ExtPrice.Name = "ExtPrice";
this.ExtPrice.ReadOnly = true;
this.ExtPrice.Width = 83;
//
// SCode
//
this.SCode.HeaderText = "S-Code";
this.SCode.Name = "SCode";
this.SCode.Width = 67;
//
// Options1
//
this.Options1.HeaderText = "Options1";
this.Options1.Name = "Options1";
this.Options1.Width = 74;
//
// Options2
//
this.Options2.HeaderText = "Options2";
this.Options2.Name = "Options2";
this.Options2.Width = 74;
//
// groupBox3
//
this.groupBox3.BackColor = System.Drawing.Color.WhiteSmoke;
this.groupBox3.Controls.Add(this.checkBox1);
this.groupBox3.Controls.Add(this.cmdApplyTaxRate);
this.groupBox3.Controls.Add(this.txtTaxRate);
this.groupBox3.Controls.Add(this.lblSubTotal);
this.groupBox3.Controls.Add(this.lblTotal);
this.groupBox3.Controls.Add(this.txtTax);
this.groupBox3.Controls.Add(this.txtShipping);
this.groupBox3.Controls.Add(this.txtShippingMethod);
this.groupBox3.Controls.Add(this.cmdTaxLookup);
this.groupBox3.Controls.Add(this.lstShipping);
this.groupBox3.Controls.Add(this.cmdBrowser);
this.groupBox3.Controls.Add(this.groupBox4);
this.groupBox3.Controls.Add(grdOrderItems);
this.groupBox3.Location = new System.Drawing.Point(14, 443);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(749, 242);
this.groupBox3.TabIndex = 13;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Order Information";
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Checked = true;
this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox1.Location = new System.Drawing.Point(253, 224);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(257, 17);
this.checkBox1.TabIndex = 21;
this.checkBox1.Text = "Automatically Apply Tax Rate with order changes";
this.checkBox1.UseVisualStyleBackColor = true;
//
// cmdApplyTaxRate
//
this.cmdApplyTaxRate.Location = new System.Drawing.Point(313, 194);
this.cmdApplyTaxRate.Name = "cmdApplyTaxRate";
this.cmdApplyTaxRate.Size = new System.Drawing.Size(126, 24);
this.cmdApplyTaxRate.TabIndex = 20;
this.cmdApplyTaxRate.Text = "Apply Tax Rate";
this.cmdApplyTaxRate.UseVisualStyleBackColor = true;
//
// txtTaxRate
//
this.txtTaxRate.Location = new System.Drawing.Point(186, 198);
this.txtTaxRate.Name = "txtTaxRate";
this.txtTaxRate.Size = new System.Drawing.Size(101, 20);
this.txtTaxRate.TabIndex = 19;
//
// lblSubTotal
//
this.lblSubTotal.AutoSize = true;
this.lblSubTotal.Location = new System.Drawing.Point(571, 128);
this.lblSubTotal.Name = "lblSubTotal";
this.lblSubTotal.Size = new System.Drawing.Size(13, 13);
this.lblSubTotal.TabIndex = 18;
this.lblSubTotal.Text = "$";
//
// lblTotal
//
this.lblTotal.AutoSize = true;
this.lblTotal.Location = new System.Drawing.Point(571, 210);
this.lblTotal.Name = "lblTotal";
this.lblTotal.Size = new System.Drawing.Size(13, 13);
this.lblTotal.TabIndex = 17;
this.lblTotal.Text = "$";
//
// txtTax
//
this.txtTax.Location = new System.Drawing.Point(561, 177);
this.txtTax.Name = "txtTax";
this.txtTax.Size = new System.Drawing.Size(182, 20);
this.txtTax.TabIndex = 16;
//
// txtShipping
//
this.txtShipping.Location = new System.Drawing.Point(561, 149);
this.txtShipping.Name = "txtShipping";
this.txtShipping.Size = new System.Drawing.Size(182, 20);
this.txtShipping.TabIndex = 15;
//
// txtShippingMethod
//
this.txtShippingMethod.Location = new System.Drawing.Point(559, 105);
this.txtShippingMethod.Name = "txtShippingMethod";
this.txtShippingMethod.Size = new System.Drawing.Size(182, 20);
this.txtShippingMethod.TabIndex = 14;
//
// cmdTaxLookup
//
this.cmdTaxLookup.Location = new System.Drawing.Point(138, 218);
this.cmdTaxLookup.Name = "cmdTaxLookup";
this.cmdTaxLookup.Size = new System.Drawing.Size(99, 21);
this.cmdTaxLookup.TabIndex = 13;
this.cmdTaxLookup.Text = "Lookup Tax Rate";
this.cmdTaxLookup.UseVisualStyleBackColor = true;
//
// lstShipping
//
this.lstShipping.FormattingEnabled = true;
this.lstShipping.Location = new System.Drawing.Point(304, 106);
this.lstShipping.Name = "lstShipping";
this.lstShipping.Size = new System.Drawing.Size(150, 69);
this.lstShipping.TabIndex = 5;
//
// cmdBrowser
//
this.cmdBrowser.Location = new System.Drawing.Point(16, 106);
this.cmdBrowser.Name = "cmdBrowser";
this.cmdBrowser.Size = new System.Drawing.Size(164, 21);
this.cmdBrowser.TabIndex = 2;
this.cmdBrowser.Text = "Launch Browser Form";
this.cmdBrowser.UseVisualStyleBackColor = true;
this.cmdBrowser.Click += new System.EventHandler(this.cmdBrowser_Click);
//
// groupBox4
//
this.groupBox4.Controls.Add(this.cmdSendRequest);
this.groupBox4.Location = new System.Drawing.Point(18, 133);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(162, 57);
this.groupBox4.TabIndex = 1;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "PayPal";
//
// cmdSendRequest
//
this.cmdSendRequest.Location = new System.Drawing.Point(7, 19);
this.cmdSendRequest.Name = "cmdSendRequest";
this.cmdSendRequest.Size = new System.Drawing.Size(131, 32);
this.cmdSendRequest.TabIndex = 2;
this.cmdSendRequest.Text = "Send Payment Request";
this.cmdSendRequest.UseVisualStyleBackColor = true;
this.cmdSendRequest.Click += new System.EventHandler(this.cmdSendRequest_Click_1);
//
// cmdClear
//
this.cmdClear.Location = new System.Drawing.Point(16, 696);
this.cmdClear.Name = "cmdClear";
this.cmdClear.Size = new System.Drawing.Size(67, 25);
this.cmdClear.TabIndex = 14;
this.cmdClear.Text = "Clear";
this.cmdClear.UseVisualStyleBackColor = true;
//
// cmdSave
//
this.cmdSave.Location = new System.Drawing.Point(91, 697);
this.cmdSave.Name = "cmdSave";
this.cmdSave.Size = new System.Drawing.Size(67, 25);
this.cmdSave.TabIndex = 15;
this.cmdSave.Text = "Save";
this.cmdSave.UseVisualStyleBackColor = true;
//
// cmdPrint
//
this.cmdPrint.Location = new System.Drawing.Point(164, 697);
this.cmdPrint.Name = "cmdPrint";
this.cmdPrint.Size = new System.Drawing.Size(67, 25);
this.cmdPrint.TabIndex = 16;
this.cmdPrint.Text = "Print";
this.cmdPrint.UseVisualStyleBackColor = true;
//
// cmdSavePrintEmail
//
this.cmdSavePrintEmail.Location = new System.Drawing.Point(393, 694);
this.cmdSavePrintEmail.Name = "cmdSavePrintEmail";
this.cmdSavePrintEmail.Size = new System.Drawing.Size(131, 31);
this.cmdSavePrintEmail.TabIndex = 17;
this.cmdSavePrintEmail.Text = "Save, Print, and Email";
this.cmdSavePrintEmail.UseVisualStyleBackColor = true;
//
// frmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Aqua;
this.ClientSize = new System.Drawing.Size(790, 725);
this.Controls.Add(this.cmdSavePrintEmail);
this.Controls.Add(this.cmdPrint);
this.Controls.Add(this.cmdSave);
this.Controls.Add(this.cmdClear);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.cmdBrowse);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.optRequestNew);
this.Controls.Add(this.optRequestShipping);
this.Controls.Add(this.optRequestAdd);
this.Controls.Add(this.cmdEdit);
this.Controls.Add(this.txtTransactionNumber);
this.Controls.Add(this.cmdLookup);
this.Controls.Add(this.cmdExit);
this.Controls.Add(this.cmdSendEmail);
this.Name = "frmMain";
this.Text = "PayPal Payment Request Program version C1";
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(grdOrderItems)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox4.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button cmdSendEmail;
private System.Windows.Forms.Button cmdExit;
private System.Windows.Forms.Button cmdLookup;
private System.Windows.Forms.TextBox txtTransactionNumber;
private System.Windows.Forms.Button cmdEdit;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button cmdBrowse;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button cmdCustomer;
private System.Windows.Forms.TextBox txtNotes;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Button cmdSendRequest;
private System.Windows.Forms.Button cmdBrowser;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button cmdApplyTaxRate;
private System.Windows.Forms.TextBox txtTaxRate;
private System.Windows.Forms.TextBox txtTax;
private System.Windows.Forms.TextBox txtShipping;
private System.Windows.Forms.TextBox txtShippingMethod;
private System.Windows.Forms.Button cmdTaxLookup;
private System.Windows.Forms.ListBox lstShipping;
private System.Windows.Forms.Button cmdClear;
private System.Windows.Forms.Button cmdSave;
private System.Windows.Forms.Button cmdPrint;
private System.Windows.Forms.Button cmdSavePrintEmail;
private System.Windows.Forms.DataGridViewTextBoxColumn Qty;
private System.Windows.Forms.DataGridViewTextBoxColumn Description;
private System.Windows.Forms.DataGridViewTextBoxColumn UnitPrice;
private System.Windows.Forms.DataGridViewTextBoxColumn ExtPrice;
private System.Windows.Forms.DataGridViewTextBoxColumn SCode;
private System.Windows.Forms.DataGridViewTextBoxColumn Options1;
private System.Windows.Forms.DataGridViewTextBoxColumn Options2;
public static System.Windows.Forms.TextBox txtEmail;
public static System.Windows.Forms.TextBox txtPhone;
public static System.Windows.Forms.TextBox txtLast;
public static System.Windows.Forms.TextBox txtCountry;
public static System.Windows.Forms.TextBox txtState;
public static System.Windows.Forms.TextBox txtAddress;
public static System.Windows.Forms.TextBox txtPayPalEmail;
public static System.Windows.Forms.DataGridView grdOrderItems;
public static System.Windows.Forms.TextBox txtZip;
public static System.Windows.Forms.TextBox txtCity;
public static System.Windows.Forms.TextBox txtName;
public static System.Windows.Forms.TextBox txtFirst;
}
}
If you look into the .designer.cs file carefully you will notice this little comment
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
Basically that part of the code are auto generated by the designer and should never be modified manually.
And yes this is considered bad practice. Firstly the control should be self contained inside the form instead of being a static one. Static just means there will only be one instance across all the forms of the same class.
Direct modification of UI from one form to another is considered anti-pattern as well. You should be making a Data model and have the UI reads the updated data when they are changed. I know this might be a bit challenging for beginners as well for winform.
So if you want to take the shortcut you can expose a public property on the other form and by modifying the property your other form will update the appropriate control.
Edit:
In the other form's code behind (.cs file)
you can do like
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public string SelectedUser { get; private set; }
}
and then in your main form you would listen to the close event
Form1 other = new Form1();
other.FormClosed += Other_FormClosed;
other.Show();
...
private void Other_FormClosed(object sender, FormClosedEventArgs e)
{
Form1 other = (Form1)sender;
string selectedUser = other.SelectedUser;
//do something
}

Move label(change position) while scrolling local ReportViewer

I have Windows Form Application. There are 2 standart controls on a form as linklabel and reportviewer. Data represented on reportViewer control sometimes so long and there possible some scrolling to keep all data for reading. It's normal situation.
But I need simple feature, when user is scrolling up or down, linkLabel should move depend scrolling values to up or down, synchronously reportViewer content. LinkLabel location must be fixed comparatively reportViewer
InitializeComponent method included:
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HRCard));
this.reportViewer1 = new Microsoft.Reporting.WinForms.ReportViewer();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.SuspendLayout();
//
// reportViewer1
//
this.reportViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.reportViewer1.LocalReport.ReportEmbeddedResource = "Kadr_Azerenerji.Report1.rdlc";
this.reportViewer1.Location = new System.Drawing.Point(0, 0);
this.reportViewer1.Name = "reportViewer1";
this.reportViewer1.Size = new System.Drawing.Size(1020, 730);
this.reportViewer1.TabIndex = 0;
this.reportViewer1.RenderingComplete += new Microsoft.Reporting.WinForms.RenderingCompleteEventHandler(this.reportViewer1_RenderingComplete);
this.reportViewer1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.reportViewer1_Scroll);
//
// linkLabel1
//
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(160, 314);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(45, 15);
this.linkLabel1.TabIndex = 2;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "Diplom";
this.linkLabel1.Visible = false;
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// HRCard
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1020, 730);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.reportViewer1);
this.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "HRCard";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Azərenerji Kadr";
this.TransparencyKey = System.Drawing.Color.LavenderBlush;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HRCard_FormClosing);
this.Load += new System.EventHandler(this.HRCard_Load);
this.Scroll += new System.Windows.Forms.ScrollEventHandler(this.HRCard_Scroll);
this.ResumeLayout(false);
this.PerformLayout();
How can I do this ?

Panel visibility not changing in C# visual studio 2010

I'm trying to do something that i would think to be rather simple. I have 2 toolstrip items.
test1: ToolStripMenuItem which should show panel -> test_panel_1
test2: ToolStripMenuItem which should show panel -> panel1
test_panel_1 contains button -> panel_1_button1 which should hide test_panel_1 and show test_panel_2
panel1 contains button -> button1 which should hide test_panel2 and then show panel2
However, when I run the code and click on test1ToolStripMenuItem it shows test_panel_1 like it's supposed to, then when i click on panel_1_button_1 it just clears test_panel_1 and doesn't show test_panel_2. And regardless of what I click first, test2ToolStripMenuItem doesn't show panel1 at all.
Here's my code...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace panel_test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void panel_1_button1_Click(object sender, EventArgs e)
{
test_panel2.Visible = true;
test_panel_1.Visible = false;
}
private void test1ToolStripMenuItem_Click(object sender, EventArgs e)
{
test_panel_1.Visible = true;
panel1.Visible = false;
}
private void button1_click(object sender, EventArgs e)
{
test_panel_1.Visible = false;
test_panel2.Visible = true;
}
private void test2ToolStripMenuItem_Click(object sender, EventArgs e)
{
test_panel2.Visible = false;
panel1.Visible = true;
}
private void button1_Click_1(object sender, EventArgs e)
{
this.panel1.Visible = false;
this.panel2.Visible = true;
}
}
}
and, not sure if this helps, but...
namespace panel_test
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (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.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.testToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.test1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.test2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.test3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.test_panel_1 = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel();
this.label3 = new System.Windows.Forms.Label();
this.test_panel2 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.panel_1_button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.menuStrip1.SuspendLayout();
this.test_panel_1.SuspendLayout();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.test_panel2.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.testToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(467, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// testToolStripMenuItem
//
this.testToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.test1ToolStripMenuItem,
this.test2ToolStripMenuItem,
this.test3ToolStripMenuItem});
this.testToolStripMenuItem.Name = "testToolStripMenuItem";
this.testToolStripMenuItem.Size = new System.Drawing.Size(38, 20);
this.testToolStripMenuItem.Text = "test";
//
// test1ToolStripMenuItem
//
this.test1ToolStripMenuItem.Name = "test1ToolStripMenuItem";
this.test1ToolStripMenuItem.Size = new System.Drawing.Size(99, 22);
this.test1ToolStripMenuItem.Text = "test1";
this.test1ToolStripMenuItem.Click += new System.EventHandler(this.test1ToolStripMenuItem_Click);
//
// test2ToolStripMenuItem
//
this.test2ToolStripMenuItem.Name = "test2ToolStripMenuItem";
this.test2ToolStripMenuItem.Size = new System.Drawing.Size(99, 22);
this.test2ToolStripMenuItem.Text = "test2";
this.test2ToolStripMenuItem.Click += new System.EventHandler(this.test2ToolStripMenuItem_Click);
//
// test3ToolStripMenuItem
//
this.test3ToolStripMenuItem.Name = "test3ToolStripMenuItem";
this.test3ToolStripMenuItem.Size = new System.Drawing.Size(99, 22);
this.test3ToolStripMenuItem.Text = "test3";
//
// test_panel_1
//
this.test_panel_1.Controls.Add(this.test_panel2);
this.test_panel_1.Controls.Add(this.panel_1_button1);
this.test_panel_1.Controls.Add(this.label1);
this.test_panel_1.Location = new System.Drawing.Point(44, 28);
this.test_panel_1.Name = "test_panel_1";
this.test_panel_1.Size = new System.Drawing.Size(442, 317);
this.test_panel_1.TabIndex = 1;
this.test_panel_1.Visible = false;
//
// panel1
//
this.panel1.Controls.Add(this.button1);
this.panel1.Location = new System.Drawing.Point(218, 187);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(328, 318);
this.panel1.TabIndex = 1;
this.panel1.Visible = false;
//
// button1
//
this.button1.Location = new System.Drawing.Point(86, 155);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "panel 3 to 4";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// panel2
//
this.panel2.Controls.Add(this.panel1);
this.panel2.Controls.Add(this.label3);
this.panel2.Location = new System.Drawing.Point(95, 194);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(398, 260);
this.panel2.TabIndex = 1;
this.panel2.Visible = false;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(86, 118);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(71, 13);
this.label3.TabIndex = 0;
this.label3.Text = "this is panel 4";
//
// test_panel2
//
this.test_panel2.Controls.Add(this.panel2);
this.test_panel2.Controls.Add(this.label2);
this.test_panel2.Location = new System.Drawing.Point(154, 101);
this.test_panel2.Name = "test_panel2";
this.test_panel2.Size = new System.Drawing.Size(358, 237);
this.test_panel2.TabIndex = 3;
this.test_panel2.Visible = false;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(70, 118);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(71, 13);
this.label2.TabIndex = 0;
this.label2.Text = "this is panel 2";
//
// panel_1_button1
//
this.panel_1_button1.Location = new System.Drawing.Point(86, 155);
this.panel_1_button1.Name = "panel_1_button1";
this.panel_1_button1.Size = new System.Drawing.Size(75, 23);
this.panel_1_button1.TabIndex = 2;
this.panel_1_button1.Text = "button1";
this.panel_1_button1.UseVisualStyleBackColor = true;
this.panel_1_button1.Click += new System.EventHandler(this.panel_1_button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(28, 21);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(42, 13);
this.label1.TabIndex = 0;
this.label1.Text = "panel 1";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(467, 357);
this.Controls.Add(this.test_panel_1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "Form1";
this.Text = "Form1";
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.test_panel_1.ResumeLayout(false);
this.test_panel_1.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.test_panel2.ResumeLayout(false);
this.test_panel2.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem testToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem test1ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem test2ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem test3ToolStripMenuItem;
private System.Windows.Forms.Panel test_panel_1;
private System.Windows.Forms.Panel test_panel2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button panel_1_button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button button1;
}
}
I've toyed with Usercontrols a little, and i like the way i can edit and view them much better than panels; however, i don't know how to control hiding and showing them.
Thanks for the help. I know this must be coding 101, but it's something i haven't quite fully figured out yet.
It looks like your test_panel_2 is a child of test_panel_1. panel1 is a child of panel2. This is likely not what you intended. What's happening is that, because test_panel_2 is inside test_panel_1, hiding test_panel_1 also hides test_panel_2. There's a hierarchy there.
There's one or two spots where you set the visibility to false again - I'm not sure if those are correct.

Not able to add a System.Windows.Controls.TextBox to groupbox controls in C#

Is there any way to add a System.Windows.Controls.TextBox to GroupBox controls in C#?
I tried the following but it doesn't show up in the groupbox:
public System.Windows.Controls.TextBox textBox6 = new System.Windows.Controls.TextBox();
public System.Windows.Controls.TextBox textBox7 = new System.Windows.Controls.TextBox();
public ElementHost sumtext = new ElementHost();
public ElementHost loctext = new ElementHost();
private void Form1_Load(object sender, EventArgs e)
{
textBox6.Name = "Summary";
textBox7.Name = "Location";
textBox6.FontFamily = new System.Windows.Media.FontFamily("Microsoft Sans Serif");
textBox6.FontSize = 12;
textBox6.SpellCheck.IsEnabled = true;
textBox7.FontFamily = new System.Windows.Media.FontFamily("Microsoft Sans Serif");
textBox7.FontSize = 12;
textBox7.SpellCheck.IsEnabled = true;
groupBox4.Controls.Add(sumtext);
sumtext.Dock = DockStyle.None;
sumtext.Width = 246;
sumtext.Height = 35;
sumtext.Child = textBox6;
sumtext.Location = new Point(3, 33);
sumtext.Visible = true;
sumtext.Enabled = false;
groupBox4.Controls.Add(sumtext);
groupBox4.Controls.Add(loctext);
loctext.Dock = DockStyle.None;
loctext.Width = 246;
loctext.Height = 35;
loctext.Child = textBox7;
loctext.Location = new Point(3, 90);
loctext.Visible = true;
loctext.Enabled = false;
this.Controls.Add(sumtext);
this.Controls.Add(loctext);
}
I need to use System.Windows.Controls.TextBox rather than Form.TextBox as I need it for spell check.
Any help would be greatly appreciated!
I changed the Enabled property of the sumtext, and removed the other box to shorten it:
This code works for me:
public Form1()
{
this.Load += new System.EventHandler(this.Form1_Load);
}
public System.Windows.Controls.TextBox textBox6 = new System.Windows.Controls.TextBox();
public ElementHost sumtext = new ElementHost();
private System.Windows.Forms.GroupBox groupBox4;
private void Form1_Load(object sender, EventArgs e)
{
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.SuspendLayout();
//
// groupBox4
//
this.groupBox4.Location = new System.Drawing.Point(57, 63);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(591, 238);
this.groupBox4.TabIndex = 0;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "groupBox1";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(706, 478);
this.Controls.Add(this.groupBox4);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
textBox6.Name = "Summary";
textBox6.FontFamily = new System.Windows.Media.FontFamily("Microsoft Sans Serif");
textBox6.FontSize = 12;
textBox6.SpellCheck.IsEnabled = true;
groupBox4.Controls.Add(sumtext);
sumtext.Dock = DockStyle.None;
sumtext.Width = 246;
sumtext.Height = 35;
sumtext.Child = textBox6;
sumtext.Location = new Point(3, 33);
sumtext.Visible = true;
sumtext.Enabled = true;
groupBox4.Controls.Add(sumtext);
}
Is this code actually getting called? Has groupbox 4 been added to the form yet?
You should not be adding your ElementHost controls to your Form AND your GroupBox, it appears to be confusing .NET. Keeping your original code exactly as-is but commenting out these two lines makes it work:
//this.Controls.Add(sumtext);
//this.Controls.Add(loctext);
Also... I don't think it's hurting anything, but you don't need to do this twice:
//groupBox4.Controls.Add(sumtext);

C# - Update textbox on forms created in code

I have a main form called mainForm - this runs my entire app.
In this form I create other forms like this:
......
......
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
}
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.
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.
Is there a way to address all the lblTimer.Text on all forms opened on the array?
Thanks,
Create your own form class which defines the Label an a method to update this method.
and then initiate all your forms using this new MyBaseForm
public MyBaseForm : Form
{
private Label lblTimer;
public MyBaseForm()
{
lblTimer = new Label();
Controls.Add(lblTimer);
}
public void UpdateTimerText(string text)
{
lblTimer.Text = text;
}
}

Categories