Using C# and VS 2003
I have two forms and a treeView, the treeView is on Form1
On Form1
Form frmAddOrgSystem = new frmAddOrgSystem();
frmAddOrgSystem.ShowDialog();
on frmAddOrgSystem
orgsystemid = Form1.treeView2.SelectedNode.Index.ToString();
I get this error:
An object reference is required for the nonstatic field... etc etc
I know I need to do something like pass a reference of Form1 to
frmAddOrgSystem, but I cant find any real clear eample of this online,
any help would be appreciated!
Bruce Wood - 28 Aug 2006 21:25 GMT
> Using C# and VS 2003
>
[quoted text clipped - 16 lines]
> frmAddOrgSystem, but I cant find any real clear eample of this online,
> any help would be appreciated!
I usually do this this way:
public class frmAddOrgSystem : Form
{
private string _orgSystemId = "";
public string OrgSystemId
{
get { return this._orgSystemId; }
set
{
if (value == null) throw new
ArgumentNullException("value");
this._orgSystemId = value;
}
}
}
then in Form1:
frmAddOrgSystem addForm = new frmAddOrgSystem();
addForm.OrgSystemId = this.treeView2.SelectedNode.Index.ToString();
addForm.ShowDialog();
...
rhaazy - 29 Aug 2006 13:21 GMT
thx
> > Using C# and VS 2003
> >
[quoted text clipped - 41 lines]
> addForm.ShowDialog();
> ...