R
Rich P
In frmMain I added a public property which returns a label contained in
frmMain:
public Label LblCD
{
get
{
return lblCurDir;
}
}
I open the 2nd form, frm2, by clicking on a button on frmMain, and in
frm2 I have this code:
frmMain fMain;
private string GetLblText()
{
return fMain.LblCD.Text;
}
the error I get when I try to invoke this proc on frm2 is:
"Object reference not set to an instance of an object."
I was thinking of trying frmMain fMain = new frmMain();
but I then I would not be able to read the current text contained in
frmMain.lblCurDir.Text.
What is the correct way to read data from another form?
Thanks,
Rich
frmMain:
public Label LblCD
{
get
{
return lblCurDir;
}
}
I open the 2nd form, frm2, by clicking on a button on frmMain, and in
frm2 I have this code:
frmMain fMain;
private string GetLblText()
{
return fMain.LblCD.Text;
}
the error I get when I try to invoke this proc on frm2 is:
"Object reference not set to an instance of an object."
I was thinking of trying frmMain fMain = new frmMain();
but I then I would not be able to read the current text contained in
frmMain.lblCurDir.Text.
What is the correct way to read data from another form?
Thanks,
Rich