Drawing textbox

MA Awan

Member
Joined
Jun 14, 2009
Messages
6
Programming Experience
Beginner
I want to draw a textbox at runtime using mouse. I know I hav to use MouseUp,MouseDown and MouseMove events to do this. But i cant find the way to set textbox's height and width. Can u plz help?
 
A TextBox is a Windows Forms control. This site has a Windows Forms forum. Please post in the most appropriate forum for the topic. Moved.

You can set the Width property of a TextBox any time but you can't set the Height of a TextBox unless the Multiline property is set to True. You can either set the Height and Width properties individually or you can set the Size property.
 
[ame="http://www.vbforums.com/showthread.php?t=426684"]This[/ame] shows you how to draw a line that is bounded by a rectangle defined by two points. You can use the same logic but just use that Rectangle to set the Bounds property of your TextBox.
 
thnx alot. I hav been able to draw it. Now i want to embed this textbox into richtextbox. i hav used rtb.controls.add method to add it. But i want to disable the area of rtb which is under this textbox so that user cant write in this area.
 
OK. Can u plz tell one more thing. I hav added some code in KeyPress event of rtb. If i add textbox into this rtb, can i somehow use the same code for textbox?
 
To attach a method to an event at run time you use the AddHandler statement, e.g.
VB.NET:
AddHandler someObject.SomeEvent, AddressOf SomeMethod
If you need to refer to the actual control that raised the event within the event handler you use the 'sender' parameter.
 
Back
Top