In vb.net, a user can inherit a new Windows control based on a control that already exists, assuming that a text control is now needed, and when you move to the control with the TAB key, the contents of the entire text are highlight, and in VB 6.0, This can be done by writing a new DLL dynamic library, but the TextBox control is blocked in the toolbox and some useful events for the textbox are lost. In VB 7.0, you can derive a new class by inheriting the TextBox class.
for an example, through the Windows design environment, create a form that has two textbox in the form, passed in the project| The Add User Control menu Adds an object named "Hitextbox.vb" to the project so that the control inherits the properties of the textbox instead of customizing a completely new control, as follows:
public class Htextbox
Inherits Textbox
First compile the entire project, and the newly added Htextbox control will appear at the bottom of the toolbar on the left. Users can create a Htextbox class object in any of the Windows Forms that are created.
in the code for the class, insert the following code to implement the highlight function: When you move to the TextBox with the TAB key, the entire contents of the TextBox become hightlight.
public class Httextbox
Inherits Textbox public
Sub New
mybase.new
' Add event event handler
AddHandler enter,_
New system.eventhandler (addressof_
me.ht_enter) End
Sub
'----------------
' Enter event handler is inside ' class
Protected Sub Ht_enter (Byval sender as Object,_
Byval e as System.EventArgs)
me.selectionstart=0
Me.selectionlength=me.text.length End Sub-end
Class
This is all the process, and by adding about 10 lines of code, you make a control that inherits from Windows controls.