[RESOLVED] Properties on a user control
I have a list within a user control that I've made, and I want to be able to access it from a class that instantiates the user control, but I'm getting a strange error.
User Control:
Code:
public partial class ctlMain : UserControl
{
private Downloads _downloads;
public Downloads DownloadList
{
get { return _downloads; }
}
...
Note that Downloads is just a public collection class that I made.
Instantiating Class:
Code:
ctlMain _ctl = new ctlMain();
foreach (DownloadItem di in _ctl.DownloadList)
{
}
The error I'm getting is:
"Error 1 'System.Windows.Forms.UserControl' does not contain a definition for 'DownloadList'"
It should also be noted that this was done in c# 2005.
Re: Properties on a user control
Have you written an explicit constructor?
Re: Properties on a user control
Yes, I have. This is it:
Code:
public ctlMain()
{
InitializeComponent();
DownloadItem di = new DownloadItem();
di.Picture = "Picture.jpg";
di.Title = "Picture Title";
di.Description = "This is the description.";
_downloads.Add(di);
/*
* Continues to do a few other things.
*/
}
Re: Properties on a user control
nevermind, I solved it myself.