Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / August 2006

Tip: Looking for answers? Try searching our database.

Access treeView.selectednode from another form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rhaazy - 28 Aug 2006 20:05 GMT
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();
> ...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.