Results 1 to 3 of 3

Thread: What is this?

  1. #1

    Thread Starter
    Addicted Member Pythagoras's Avatar
    Join Date
    Feb 2005
    Location
    Greece
    Posts
    137

    What is this?

    What I'm trying to do is clone a panel with some controls on it??

    I recieve this error message:
    'Panel1' is a 'field' but is used like a 'type'



    Here is my code:
    VB Code:
    1. Panel1 pnl = (Panel)new Panel1();
    2. pnl.Left = 25;
    3. pnl.Top = 200;
    4. this.Controls.Add(pnl);

    What is going on here?
    Visual Studio.Net 2003

    "Every man has been made by God in order to acquire knowledge and contemplate."
    --Pythagoras

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

    Re: What is this?

    A field is a member variable, so the error is saying that you are using a member variable as though it was a type. If you've added a Panel to your form in the designer and named it "Panel1" then you have created a member variable named Panel1, not a class named Panel1 that you can create instances of, which your first line is trying to do. Perhaps you need to create a UserControl if you want to use a set of controls in more than one place.
    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
    Addicted Member Pythagoras's Avatar
    Join Date
    Feb 2005
    Location
    Greece
    Posts
    137

    Re: What is this?

    Thanks for the reply!

    Looks like I'll have to crate a user control.
    Visual Studio.Net 2003

    "Every man has been made by God in order to acquire knowledge and contemplate."
    --Pythagoras

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