Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing control on form from another class 1

Status
Not open for further replies.

TiltingCode

Programmer
Apr 10, 2009
61
US
I have the following form:
Code:
namespace MySpace_SomeSpace
{
 public partial class frmABC : Form
  {
     .....code here......
  
  }
}

On this form is a list control where I want to add to the list from another class but I'll need to pass some parameters to add text to the control.

It appears I'll need to create another partial class from the other class but everything I do is coming up with errors:
Code:
namespace MySpace2_SomeSpace
{
    public partial class frmABC(NameValueCollection FieldCollection)
    {
      lstCompose.Items.Add("Building " + FieldCollection["ComposePath"].ToString() + "\\" + FieldCollection["DocumentName"].ToString());
    }
}

There is no code referencing this control on the form where the control exists (frmABC). I don't know if this matters but am adding this comment in case it does.

I'm assuming that since MySpace2_SomeSpace is not a form the ": FORM" had to be removed?

Any help is appreciated.


 
not a partial class, just another class. you can then pass the form to the "other" class. the other class is the one you design... from scratch.

[tt]MySpace2_SomeSpace[/tt] is the namespace, it's just a logical container to group objects. the actual form is [tt]frmABC[/tt].

You may want to research the design concepts of Model View Presenter (MVP). This is a common practice (with various implementations) for desktop applications.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top