PC Review


Reply
Thread Tools Rate Thread

Abt. extending windows form control

 
 
rajendra
Guest
Posts: n/a
 
      8th Sep 2003
how to extend existing windows forms control like if i
want to add new add method to combo box ,how to go abt. it?
can anyone help me abt. this
 
Reply With Quote
 
 
 
 
Tom Spink
Guest
Posts: n/a
 
      8th Sep 2003
Hi, first off, you need to create a class. Then that class inherits from
what you wish to extend. You add your extra methods/properties and compile
your assembly. You can then add your assembly to your toolbox, and see your
new control:

'///
Public Class MyComboBox
Inherits System.Windows.Forms.ComboBox

Public Sub New()
MyBase.New()
End Sub

Public Sub MyCustomMethod()
MsgBox("Hello, World.")
End Sub
End Class
'///

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"


"rajendra" <(E-Mail Removed)> wrote in message
news:350e01c375d0$f96810a0$(E-Mail Removed)...
> how to extend existing windows forms control like if i
> want to add new add method to combo box ,how to go abt. it?
> can anyone help me abt. this



 
Reply With Quote
 
Fergus Cooney
Guest
Posts: n/a
 
      8th Sep 2003
Hi Rajendra,

It's in fact very easy to do:

Here's the article in MSDN. Note that the URL is split. You'll have to
join the two lines to follow the link.

http://msdn.microsoft.com/library/de.../vbcon/html/vb
conwalkthroughcreatingcompositewfccontrol.asp

I've copied part of the page for you to read here.

If you want to extend the functionality of an existing control, you can
create a control derived from an existing control through inheritance. When
inheriting from an existing control, you inherit all of the functionality and
visual properties of that control.

For instance, if you were creating a control that inherited from Button,
your new control would look and act exactly like a standard Button control.
You could then extend or modify the functionality of your new control through
the implementation of custom methods and properties.

In some controls, you can also change the visual appearance of your
inherited control by overriding its OnPaint method.

To create an inherited control

1]. Create a new Windows project.
This project can be of any type, such as a Windows Application project or a
Windows Control Library project. If you choose a Windows Control Library, you
may use the blank control provided and skip steps 2 and 3.

2]. From the Project menu, choose Add Inherited Control.
The Add New Item dialog box appears.

3]. In the Add New Item dialog box, double-click Custom Control.
A new custom control is added to your project.

4]. In the Code Editor, locate the line that specifies Control as the base
class to inherit from. Change the name of the base class to the name of the
control from which you want to inherit.

For example, if you want to inherit from Button, the line would read:
Inherits System.Windows.Forms.Button

Regards,
Fergus


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      8th Sep 2003
Hello,

"rajendra" <(E-Mail Removed)> schrieb:
> how to extend existing windows forms control like if i
> want to add new add method to combo box ,how to go abt. it?
> can anyone help me abt. this


http://msdn.microsoft.com/library/en...fccontrols.asp

--
Herfried K. Wagner
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


 
Reply With Quote
 
Fergus Cooney
Guest
Posts: n/a
 
      8th Sep 2003
Hi Rajendra,

Right article but wrong link. I copied in the link to the page I was on
beforehand.

Herfried has given the correct link in the post below mine.

Regards,
Fergus


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
extending the gridview control Robert Smith Microsoft ASP .NET 0 4th Jun 2008 03:55 PM
Extending a windows control Dom Microsoft C# .NET 0 21st Dec 2007 04:09 PM
Modaly Load A Windows Form User Control From Another Windows Form User Control - Sort of like a popup. Richard Microsoft Dot NET Framework Forms 1 4th Apr 2005 11:44 PM
Modaly Load A Windows Form User Control From Another Windows Form User Control - Sort of like a popup. Richard Microsoft VB .NET 1 4th Apr 2005 11:44 PM
Modaly Load A Windows Form User Control From Another Windows Form User Control - Sort of like a popup. Richard Microsoft C# .NET 1 4th Apr 2005 11:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:26 PM.