Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unable to create custom controls
Message
From
13/07/2006 12:18:10
 
 
To
13/07/2006 07:33:06
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01135960
Message ID:
01136074
Views:
11
>i am new to vb.net and i dont know how to create custom contols in vb.net and i am also not getting it into any book..plz tell me the steps for creating contols or tell me any book or ebook which in detail cover this topic.<

OK, this is C# code, but the basic concepts are the same:

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.

To add to a ToolBox:

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.

~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

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

Click here to load this message in the networking platform