Results 1 to 4 of 4

Thread: [RESOLVED] Properties on a user control

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    20

    Resolved [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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Properties on a user control

    Have you written an explicit constructor?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    20

    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.             
                 */
            }

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    20

    Re: Properties on a user control

    nevermind, I solved it myself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width