PDA

Click to See Complete Forum and Search --> : What is this?


Pythagoras
Dec 27th, 2005, 09:11 PM
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:

Panel1 pnl = (Panel)new Panel1();
pnl.Left = 25;
pnl.Top = 200;
this.Controls.Add(pnl);

What is going on here?

jmcilhinney
Dec 27th, 2005, 09:19 PM
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.

Pythagoras
Dec 27th, 2005, 09:31 PM
Thanks for the reply!

Looks like I'll have to crate a user control.