inherits.system.windows.forms.usercontrol

mshahid

Active member
Joined
Aug 23, 2012
Messages
29
Programming Experience
Beginner
i am new in vb.net. i could not find the window where i find inhetirs.system.windows.forms.usercontrol.

kindly help me

Thanks
 
Dear I want to develop custom TextBox Control i could not find control code window in which i changed

Inherits system.windows.forms.usercontrol to inherits TextBox
 
You don't change that. Either you're creating a UserControl or you're creating a custom TextBox. If you're creating a UserControl then add a UserControl to your project and leave it as a UserControl. If you're creating a custom TextBox, or any other custom control for that matter, then just add a Class to your project and then add the Inherits line to the one and only code file. Here's an example of where I did exactly that:

Numeric Text Box

No UserControls in sight.
 
I could not understand which you mention. thanks for your advice but I wanted to build focusedtextboxcontrol.

Below mention is the task which I performed. Kindly let me know where is the problem.

First I insert the windows control library after inserting usercontrol.vb file is appear then I rename the usercontrol1.vb to focusedtextbox . Then I insert the customcontrol but when I go to view code I could not find the inherits systems.windows.Forms.usercontrol1. so where I changed inherits.Textbox

Please let me know where I make mistake.
 
Hi,

To extend the functionality of an existing control all you have to do is add a new class to your project and then inherit the object type that you want to extend. In your case what you need to do is add a class called FocusedTextBox and then use the following example:-

Public Class FocusedTextBox
Inherits TextBox
'add your additional embellishments here
End Class

Hope that helps.

Cheers,

Ian
 
Thanks dear

with your help I build the Focused TextBox control. but the problem is the when i run the focusedtextbox the usercontro library is appear. not focusedtextbox which i build.

how can i fix this.

Thanks
 
Hi,

I am not sure I understand you here? Are you saying that when you run what you have you get the UserControl TestContainer panel displayed? If so then I think you have got a little mixed up with the comments that have been provided to you.

To make this easy, let's go back to the start for a moment and go from there:-

1) Create a new Windows Forms Application which then adds the default Form1.

2) In the solution explorer add a new class and call it FocusedTextBox.

3) In the FocusedTextBox class add the code that you have already written for your FocusedTextBox and then save and close your class.

4) Select the Form1 design tab and then open the Tool Box. You will notice that at the top of the toolbox you will have a new WindowsApplication(x).Components tab added to the tool box. In this tab you should see your newly created FocusedTextBox control which you can then drag and drop onto your Form1 as many times as you need.

5) From here you can then run your application and see your new control working as you need.

In the above example the FocusedTextBox can only be used in the context of the current project. If you then need to create an external DLL file for this control to be used in other applications then post back and we will provide additional guidance as needed since I do not want to confuse you with that issue here. The point here is to get you working with your custom control.

Hope that helps.

Cheers,

Ian
 
Back
Top