Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2005, 12:32 PM
Registered User
 
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Extending Controls Question

Greetings:

I have recently set out to learn how to extend some of the Windows forms controls that are supplied with VS. I'm using C#. Specifically, I wanted ListView to be able to display small images in sub-items ("Detail" mode only), rather than just the left-most item in the list.

I have examined several examples where people have extended ListView and some other controls to make them more versatile and flexible, etc. and I have noticed something that I find puzzling:

Of the ListView examples that I studied 3 of them started by deriving their new class from System.Windows.Forms.Control. This means that they essentially redesigned a list view from the ground up and made it better, instead of deriving their new class from the existing ListView. The code is excessively complicated and difficult to follow for somebody who is new to C# and simply wants to implement a minor extra feature.

The other 2 examples that I studied, did derive their extended class from ListView but BOTH of them ended up importing the User32.DLL and implementing SendMessage calls in order to accomplish what they wanted.

I am in no position to question the wisedom of either approach, I am just a bit surprised with how difficult it is to extend the capability of an existing control without:
A) Starting over from scratch (ie: not extending the original control at all)
B) Resorting to User32 calls

I was led to believe that extending controls was one of the strengths of C#. Why does it seem that in order to add some minor functionality to an existing control, one has to basically break from the .NET environment and haul in imported Win32 calls? Or worse yet, why did 3 of the examples imply that the authors felt so constrained by the control base classes that they simple thought it easier to start over?

Or did I just encounter 5 really bad examples? Somehow, I doubt that.

I welcome any thoughts and reflections that some of you more seasoned programmers may have.

Thank you,
Mark







Similar Threads
Thread Thread Starter Forum Replies Last Post
Extending the CMS retroviz BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 April 23rd, 2008 07:00 AM
Extending DataGridItem Phrozen ASP.NET 2.0 Professional 0 March 11th, 2007 09:17 AM
Events in User Controls question Aaron Edwards ASP.NET 1.0 and 1.1 Basics 1 December 6th, 2005 02:59 PM
Controls question Warbird General .NET 0 January 25th, 2005 11:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.