Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

create a class derived from a Panel

Posted on 2003-11-17
5
265 Views
Last Modified: 2010-04-16
Experts,

I am trying to create a class, MyPanel, which is derived from System.Windows.Forms.Panel.

Then I wanted to add a couple of standard controls to MyPanel. I couldn't find a way to specify their properties by using design view. All I have to do is to write code to define properties like Location and Size. As I am doing it, I have no any clue how does it look like and if it fits with other controls. then I have to run the program to actually see the appearance of the panel and its containing controls.

If I create a class derived from System.Windows.Forms.UserControl, it seems solve the problem. I can design the controls in a visual view. But it makes the code bigger. I wonder if it effects the performance and code efficiency.

Any better ideas or suggestions?
Thanks
0
Comment
Question by:stone123
  • 2
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
smegghead earned 150 total points
ID: 9767099
I have come across exactly this problem, it's a shame that the designed doesn't cope with inherited controls.

The way I got around this was to have a separate project which contains the definition of my panels, just created normally on a form, then I just cut and paste the 'windows form designer generated code' section to my inherited panel. This works fine, although it's a bit fiddly.

Hope this helps a bit.

Smg.
0
 
LVL 1

Expert Comment

by:AJMartin
ID: 9769806
One alternative is use an automatic layout manager class, that way, you don't really need to have a design time view. :)

Or, you could check out this article on MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconenhancingdesign-timesupport.asp

Here's a quote:
"For example, if you define a property of a custom type on a control, you can provide a custom user interface, or type editor, to edit the value of that property using a property browser. You can build a class called a designer that can manage a variety of aspects of a component or control's appearance and behavior at design time."

I hope that helps!
0
 
LVL 1

Author Comment

by:stone123
ID: 9772269
Thanks, Smg and AJMartin. Your suggestions help.
I am using a System.Windows.Forms.UserControl, it works just fine. I wonder if there is any potential problems in the future in my case of implementation.
Can any one have a little comment on the UserControl object? What is your experience of using it?
0
 
LVL 10

Expert Comment

by:smegghead
ID: 9772322
It's very good for what it's designed for, and if it solves your problem, then I can't see there being any problem with it. It's probably going to be a bit bulkier than directly coding your classes individually, but if it makes it easier to use / maintain, then go for it.

Smg.
0
 
LVL 1

Author Comment

by:stone123
ID: 9780827
ok, looks like no more inputs from your guys. then I go ahead to close the thread and give out the points.
Smg, what you advised is quite a good work-around. Thanks a lot.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
designing in object programming 12 94
Best resource to learn entity framework 2 47
Service Controller 1 28
Adding items to a C# list incrementally 5 33
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question