Hello:
In a routine I need to populate the TextBoxs in a Form. How do I assign a form that I only have the string of the Form name? Not sure how to explain this. If someone replys to this post, I can maybe explain it better if questions are asked.
Below is the code that I have started:
for (TheRow = 0; TheRow < FormICEPack.dataGridViewRecord.Rows.Count - 1; TheRow++)
{
TheColumnName = FormICEPack.dataGridViewRecord.Rows[TheRow].Cells["Column"].Value.ToString();
TheValue = FormICEPack.dataGridViewRecord.Rows[TheRow].Cells["TheValue"].Value.ToString();
MessageBox.Show("L-0617: TheRow=" + TheRow + " TheColumnName=" + TheColumnName + " TheValue=" + TheValue);
//Form_ID + ".textBox" + TheColumnName + ".Text" = TheValue;
//FormCompany.textBoxAddress_1.Text = TheValue;
}
Loading
PJ MartinsPosted May 26, 2010, 5:51 PM
You'd most likely need something like this:
Form frm = (Form)Controls.Find("Form_ID", true);
TextBox txt = (TextBox)frm.Controls.Find("textBox" + The ColumnName, true);
txt.Text = TheValue;