That removed the error, but introduced another. I now get an error on the same line but is is under FormA.PanelA stating: An object reference is required for the non-static field, method or property. txtQtyB.Text = FormA.panelA.txtQtyA.Text; I'm not sure how I can change the accessor for a dynamically created control? And just to add a little more. FormA creates and calls FormB.
KakitaIppatsu
Posts
-
Moving Data from one form to another -
Moving Data from one form to anotherI'm trying to take data collected on a form, and output it to another form, but I'm getting an "inaccessible due to its protection level" error. So I have form A, that has a panel with some dynamically generated textboxes. FormA -> panelA -> txtQtyA In Form B, I want to access the data, and I'm trying to use: txtQtyB.text = FromA.panelA.txtQtyA.Text, but I get the error for panelA. I have tried changing the forms constructor to Public, just to see if it would "see" it with no luck. Any assistance would be appreciated.
-
Creating Events with Dynamically created ComboBox(es)Sorry to not respond earlier, but your solution works perfectly. Thanks all for your help!:thumbsup:
-
Creating Events with Dynamically created ComboBox(es)I have created X number of ComboBoxes (PartNo) dynamically, that depending on the number selected in it, it will pull/populate some textboxes with Part Information. All boxes have been given a Key value of cboBox1, cboBox2, etc. How can I make an event for these comboboxes?
private void cboBox1_SelectedIndexChanged(object sender, EventArgs e)
Not sure if it matters, but the comboboxes are all part of a panel (pn), so maybe it would be?
private void pn.cboBox1_SelectedIndexChanged(object sender, EventArgs e)
I hate not knowing what I don't know.
-
Accessing dynamically generated textboxesGentlemen, I wanted to thank you for your help. Both of you got me going again.
-
Accessing dynamically generated textboxesOk, so I follow what you did with the code. Having difficulty in taking it to the next step. My thoughts are, I should now be able to:
tbProd.Text = "Blah";
However, I get the following error: 'System.NullReferenceException'in Project.exe ("Object reference not set to an instance of an object.") And to make sure I really do understand what you suggested:
TextBox tbProd = (TextBox)pn.Controls.Find("txtProdName" + i, false).FirstOrDefault();
Creating a new instance of a textbox, called tbProd that is being set to the first control found in the panel, pn with a name of txtProdName + i, and casting that to type textbox. If I truly understand your code, and the error, it would appear that tbProd didn't actually get the copy I thought it did?? I truly want to thank you for your help.
-
Accessing dynamically generated textboxesI have dynamically created textboxes in a loop, and given them names at creation time.
txtProdName.Name = "txtProdName" + i;
pn.Controls.Add(txtProdName);
txtProdDesc.Name = "txtProdDesc" + i;
pn.Controls.Add(txtProdDesc);The above snippet works fine. Controls are created, and removed as needed. Now, I would like to go back and read or write information into these textboxes, but I'm at a lost as to how to address them. I'm trying to do something like:
txtProdName + i.Text = "Blah";
txtProdDesc + i.Text = "Blah2";Now I know the above code won't work, but wondering if there is someway to do something similar? Or am I totally barking up the wrong tree. Thanks in advance. P.S. I haven't found an answer to this anywhere, which leads me to believe I'm at the wrong tree. :-D