473,804 Members | 3,822 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form.ControlCol lection - overrideable?

Is it possible to extend the Windows.Forms.F orm.ControlColl ection
class and override it's Add method?

I'm adding controls to a Form and want to [automatically] hook up
Event Handling for the Form to deal with on behalf of each Control.
I /thought/ the best way to do this would be to inherit from and
override the Add method on the Form.ControlCol lection class and
put some AddHandler statements in there. This much I can do but the
bit I'm missing is how to get the Form to use /my/ ControlCollecti on
rather than the standard one.

Any suggestions?

TIA,
Phill W.
Nov 20 '05 #1
3 2352
Phill. W schrieb:
Is it possible to extend the Windows.Forms.F orm.ControlColl ection
class and override it's Add method?

I'm adding controls to a Form and want to [automatically] hook up
Event Handling for the Form to deal with on behalf of each Control.
I /thought/ the best way to do this would be to inherit from and
override the Add method on the Form.ControlCol lection class and
put some AddHandler statements in there. This much I can do but the
bit I'm missing is how to get the Form to use /my/ ControlCollecti on
rather than the standard one.


Did you see the form's 'ControlAdded' event?

<URL:http://msdn.microsoft. com/library/en-us/cpref/html/frlrfsystemwind owsformscontrol classcontroladd edtopic.asp>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Phill,
In addition to deriving a new class from Control.Control Collection and
overriding some of its methods. To get Control to use your new class you
need to override Control.CreateC ontrolsInstance to create a new instance of
your ControlCollecti on.

However!! I would do as Herfried suggested & handle the Control.Control Added
& Control.Control Removed events.

Note the above are advanced members VB.NET normally hides them in both the
Object Browser & the code editor. Use "Show hidden members" in the object
browser to see them, use "Tools - Options - Text Editor - Basic - General -
Hide advanced members" to see them in the code editor.

Hope this helps
Jay

"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:c7******** **@yarrow.open. ac.uk...
Is it possible to extend the Windows.Forms.F orm.ControlColl ection
class and override it's Add method?

I'm adding controls to a Form and want to [automatically] hook up
Event Handling for the Form to deal with on behalf of each Control.
I /thought/ the best way to do this would be to inherit from and
override the Add method on the Form.ControlCol lection class and
put some AddHandler statements in there. This much I can do but the
bit I'm missing is how to get the Form to use /my/ ControlCollecti on
rather than the standard one.

Any suggestions?

TIA,
Phill W.

Nov 20 '05 #3
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
Phill. W schrieb:
Is it possible to extend the Windows.Forms.F orm.ControlColl ection
class and override it's Add method?

I'm adding controls to a Form and want to [automatically] hook up
Event Handling for the Form to deal with on behalf of each Control.
I /thought/ the best way to do this would be to inherit from and
override the Add method on the Form.ControlCol lection class and
put some AddHandler statements in there. This much I can do but the
bit I'm missing is how to get the Form to use /my/ ControlCollecti on
rather than the standard one.


Did you see the form's 'ControlAdded' event?

<URL:http://msdn.microsoft.com/library/en...ystemwindowsfo
rmscontrolclass controladdedtop ic.asp>

Many thanks, Herfried; just what the Doctor ordered ...

And, of course, thanks once again to Our Friends in Redmond's
and their utterly /impenetrable/ documentation. ;-)

Regards,
Phill W.
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3622
by: James Marshall | last post by:
I'm trying to override location.replace() but I can't. I can override window.open(), document.write(), and other built-in methods, but not location.replace(). Here's a demo that overrides two built-in methods, then reports on them: location.replace= function (url) { alert(url) } ; alert('location.replace=\n'+location.replace) ; document.write= function (html) { alert(html) } ; alert('document.write=\n'+document.write) ;
0
1761
by: Christo14 | last post by:
When I make a form with the form designer the result is a form with significantly fewer properties and meathods than if I made a form from scratch. The properties and meathods I currently have in Visual C# are :ActiveForm, ControlAccessibleObject, ControlCollection, DefaultBackColor, DefaultFont, DefaultForeColor, DockPaddingEdges, DockPaddingEdgesConverter, Equals, FromChildHandle, FromHandle, GetAutoScaleSize, IsMnemonic, Main,...
6
3039
by: DraguVaso | last post by:
Hi, Is there actually a way to get ALL the Controls on a Form? While using the ControlCollection, it only returns the Controls that are directly on the Form, not the controls that are on a (TableLayout)Panel etc. I never found something like that, but it just would be nice in my opinion :-) Thanks,
0
1764
by: Harry F. Harrison | last post by:
Here's the situation...Context - Using an Inherited WebControl object as a base for server custom controls. In a web custom control, whenever I create a child control and add it to the Controls class, it takes 3 lines of code. Example: Dim TextBox as System.Web.UI.WebControls.TextBox 1..TextBox = New System.Web.UI.WebControls.TextBox
2
1491
by: magister | last post by:
Hello, I have a asp.net page with a form with 15 textboxes and a couple of dropdownlists....I want to know if their is a way (...serverside please...) of checking if any change has been made to any of these controls before I send and update to the database....I would rather not have a OnTextChanged & OnSelectedItemChanged with postback set to false for every control on the page... I have been trying to implement the IPostBackEventHandler...
1
1676
by: DanielSchaffer | last post by:
I am trying to create a class that inherits fromControlCollection, but I am getting the compile error "Nooverload for method 'ControlCollection' takes '0' arguments",and VS highlights the constructor method: public AvailabilityCollection(Control owner) { _owner = owner; } Here is what the .NET SDK has for the ControlCollectionconstructor: public ControlCollection( Control owner );
2
4555
by: D Hass | last post by:
Radio Buttons are added to my form During the Load event, the quantity determined by User input. They are placed in pairs on groupboxes with code like this: (edited a bit for brevity) Public Function LayoutForm(ByVal intNumber As Integer) Dim intCount As Integer Panel1.Controls.Clear() For intCount = 1 To intGames
2
1528
by: Michael Beck | last post by:
I am new to .net programming and I want to know if I can loop thru a specified number of controls on an html form. In Access, the code looks like this: For i = 1 to 10 Me("txtAlternate" & i) = "" Next i Is there an equivalent code in asp.net?
7
1708
by: forest demon | last post by:
all i want is to do is to pass a form reference to a separate class and be able to manipulate properties/components/controls of said form. this should be as simple as passing a TextBox, Container object or something similar, to do the same, but no. what am i missing, besides my mind? thanks folks...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9150
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.