Resize Form and Detect Size In TextBox

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
2 posts Page 1 of 1
Contributors
User avatar
mikethedj4
VIP - Site Partner
VIP - Site Partner
Posts: 2592
Joined: Thu Mar 25, 2010 4:36 am

Got two textbox's one represents the form's width, and the another height.

When the form loads it displays the size of the form's width, and height in each textbox.

When you resize the form it'll automatically update the text in the texbox's and tell you what the form's current size is.

How can I do this?

EDIT:
I figured it out, here's the code for those that want to do the same.
Code: Select all
	Private sizew As Integer
	Private sizey As Integer

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		TextBox1.Text = Me.Size.Width()
		TextBox2.Text = Me.Size.Height()
	End Sub

	Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
		TextBox1.Text = Me.Size.Width()
		TextBox2.Text = Me.Size.Height()
		sizew = TextBox1.Text
		sizey = TextBox2.Text
		Me.Size = New System.Drawing.Size(sizew, sizey)
	End Sub
Last edited by mikethedj4 on Fri Jul 20, 2012 7:48 pm, edited 1 time in total.
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

i think you must use
Code: Select all
me.top = textbox1.text
me.left = textbox2.text
to resize:
Code: Select all
    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
me.top = textbox1.text
me.left = textbox2.text
    End Sub
or
Code: Select all
Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
        MyBase.OnResize(e)
'do something
End Sub
or
Code: Select all
Private Sub FORMLogDetails_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
me.top = textbox1.text
me.left = textbox2.text
    End Sub
just looking at my old project from home money manager maybe this helps.
not sure not using vb
just a guess.
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
2 posts Page 1 of 1
Return to “Coding Help & Support”