Solved

create a class derived from a Panel

Posted on 2003-11-17
5
269 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
[X]
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
  • 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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 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