Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to subclass control?
Message
From
08/04/2007 12:53:20
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01184867
Message ID:
01213276
Views:
24
No problem, Dmitry.

When you have the IDE open in the designer view (not the code view), go to the ToolBox, right-click anywhere and choose the Add/Remove Items (in 2.0, it's "Choose Items..."), click on Browse and find the .DLL where your sub-classed controls are (you obviously needed to have compiled the class library after you created it). That's it ... they'll then be added to your ToolBox.

They will be in your Toolbox for all Solutions.

~~Bonnie



>Bonnie,
>
>Sorry for adding a message to an old thread.
>
>Could you please tell me how to add your own class library to the VS Toolbox? And, if I do so, will this class library appear in the Toolbox in all my solutions, or just one solution?
>
>Thank you.
>
>>John,
>>
>>Basically, you'll want a class library that contains your sub-classed UI controls, like textbox, button, etc. Something like this:
>>
>>using System;
>>using System.Drawing;
>>using System.Collections;
>>using System.ComponentModel;
>>using System.Windows.Forms;
>>using System.Data;
>>
>>namespace MyCompany.WinUI.MyClasses
>>{
>>	public class MyComboBox : System.Windows.Forms.ComboBox
>>	{
>>		// code here
>>	}
>>
>>	public class MyTextBox : System.Windows.Forms.TextBox
>>	{
>>		// code here
>>	}
>>
>>	public class MyButton : System.Windows.Forms.Button
>>	{
>>		// code here
>>	}
>>}
>>
>>That's it. These controls can't be sub-classed visually, but as you can see, it's easy enough to do it in code. I have all the basic controls sub-classed in one class library file. Once they're added to the ToolBox, then can be dragged onto any design surface in the IDE.
>>
>>~~Bonnie
>>
>>
>>
>>>Hi,
>>>Which one which I use to subclass label control, component or control?
>>>
>>>I did use component to subclass linklabel, when I drop it to form, VS will just shutdown.
>>>
>>>Thank you
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform