View Full Version : Resizing of the text box in VB
ankumarank
February 7th, 2007, 06:28 AM
Hi Everybody,
I am having Visual Studio 2005 Express edition with me. What I want to accomplish is that in a form I am creating two text boxes along with some other controls. The user should have the option of resizing the text boxes on the fly. Please advice.
Warm Regards,
Ankumarank.
Templarian
February 7th, 2007, 08:56 AM
Do what the design panel does in VS, and just put like an small small box in the bottom right of the textbox that when dragged increase txtbox.width and txtbox.height.
By box just use a simple picture box with the colour black and make it 6x6pixels and lay it in the corner. Make sure to code it all off the txtbox's position.
ankumarank
February 8th, 2007, 12:06 AM
Hi, thanks for the response. I am a newbie to the vb. Could you elaborate a little bit more.
Thanks in Advance,
Warm Regards,
Ankumarank.
Templarian
February 8th, 2007, 12:54 AM
Public Class Form1
Dim resize1 As Point
Dim down1 As Boolean
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
resize1.X = e.X + PictureBox1.Left
resize1.Y = e.Y + PictureBox1.Top
TextBox1.Text = e.X & " " & e.Y
down1 = True
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If down1 = True Then
TextBox1.Text = e.X & " " & e.Y
PictureBox1.Left = (PictureBox1.Left - 4) + e.X
PictureBox1.Top = (PictureBox1.Top - 4) + e.Y
TextBox1.Width = PictureBox1.Left - TextBox1.Left + 4
TextBox1.Height = PictureBox1.Top - TextBox1.Top + 4
resize1.X = e.X
resize1.Y = e.Y
End If
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
resize1.X = e.X
resize1.Y = e.Y
down1 = False
End Sub
End Class
make a text box and a picture box (8x8). Then copy it over. You will have to make the textbox multiline i believe to test it out. its 12 at night here to tired to explain everything. You will want to set limits for textbox min height and stuff btw.
BTW, tell me if this is what you meant.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.