You wont be able to immediately assign values from 1 forms control to
another unless the controls are public on the verify form.
However I would not recommend making these controls public as that ruins
encapsulation.
Either, create public properties to access the controls on the other form or
create an intermediate object to carry the data across.
E.G.
class Form1:Form
{
private void btnSubmit_Click(object sender, EventArgs e)
{
FormVerify verify = new FormVerify();
VerficationData data = new VerficationData();
data.Program = grpProgram;
data.FirmName = txtFirm.Text;
data.InvoiceNumber = txtInvoiceNumber.Text;
verify.Initialize(data);
verify.ShowDialog();
}
}
class FormVerify:Form
{
public void Initialize(VerificationData data)
{
lblFirmName.Text = data.FirmName;
lblProgramType.Text = data.Program.
lblInvoiceNumber.Text = data.InvoiceNumber;
}
}
class VerficationData
{
string program;
string firmName;
string invoiceNumber;
public string Program
{
get{return program;}
set{program = value;}
}
public string FirmName
{
get{return firmName;}
set{firmName = value;}
}
public string InvoiceNumber
{
get{return invoiceNumber;}
set{invoiceNumber = value;}
}
}
HTH
Simon Tamman
<wa****@yahoo.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
I thought I had it figured out but I'm still getting errors :( I would
appreciate any help I could get.
I have two forms: Form1 and frmVerify. Once the info gets submitted on
Form1 its text fields are transfered to some label fields to frmVerify.
Sounds easy but I keep getting "System.Windows.Forms.Groupbox' does not
contain a definition for 'verifyForm'
Here is that part of the code:
private void btnSubmit_Click(object sender, EventArgs e)
{
frmVerify verifyForm = new frmVerify(); //initialazing
Form2 (frmVerify)
if (condition)
MessageBox.Show(...)
else
{
verifyForm.lblFirmName.Text = this.txtFirm.Text;
verifyForm.lblProgramType.Text = this.grpProgram.
verifyForm.lblInvoiceNumber.Text = this.txtInvoiceNumber.Text;
verifyForm.ShowDialog();
}
Any suggestions ?
Thank you.