How to Edit my Derived Panel in Visual Designer

Z

zhaodapu

I derived a panel class:

public class DeskPanel : System.Windows.Forms.Panel

Now I want to use the visual designer to add controls in MyPanel
class. But I noticed that the visual designer didn't work.

I try some other ways, and found the if i derived my panel from
UserControl class it works. However, I thought deriving from Panel is
more rational. I have several panels (such as calendar panel, contacts
panel, photo viewer... and I will switch them in my main form base on
the user choice)
 
A

.\\\\axxx

I derived a panel class:

public class DeskPanel : System.Windows.Forms.Panel

Now I want to use the visual designer to add controls in MyPanel
class. But I noticed that the visual designer didn't work.

I try some other ways, and found the if i derived my panel from
UserControl class it works. However, I thought deriving from Panel is
more rational. I have several panels (such as calendar panel, contacts
panel, photo viewer... and I will switch them in my main form base on
the user choice)

If you mean that you are trying to add controls to your pane at design
time when your panel hasn't been dropped onto a Form (or other
control) then you can't (to my knowledge). What you need to do is to
create a user control (not a panel) then add your controls onto that
at design time (as you have discovered).
What is is about Panel that you think is more logical than
UserControl? You can have several of them, and switch between them
exactly as you can a panel - in fact the main difference between a
Usercontrol and a panel would seem to be that you can do what you
require with a UserControl and you can't with a Panel!

Of course, if you REALLY want to use Panel, then you need to put that
panel onto something to be able to design it, so you could put it on
your form, add controls to it, make it invisible, add our other
panels, do the same etc.
 
Z

zhaodapu

It really helps me to make my decision. Thanks a lot.

I thought use Panel is more logical because I thought a UserControl
should be a general and reusable component. What I need is just a
collection of controls like buttons and textboxs. I did the same thing
when I use Java Swing and Jbuilder. Troubles happen when I study
Csharp with Java in mind.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top