Solved

Resize form -> Adjust TextBox

Posted on 1998-09-24
3
402 Views
Last Modified: 2006-11-17

How do I create a form that when the user resize the form the TextBox will adjust to the size of the form ?

Also the buttons in the form must move.
0
Comment
Question by:jfl
3 Comments
 
LVL 3

Expert Comment

by:vmano
ID: 1436532
There are very good Elastic ActiveX controls which will do the same for you from green-tree software. you can check out their site at
http://www.green-tree.com/components_Main_Frame.htm. i think they have 30 day evaluation deal and you can try that.

let me know if this helps,
vmano
0
 

Author Comment

by:jfl
ID: 1436533
I don't have the money for that...Sorry
0
 
LVL 4

Accepted Solution

by:
trkcorp earned 20 total points
ID: 1436534
I thought I submitted this answer but I got your rejection of vmano & it wasn't there!!! So, if you already have this forgive me for resubmitting.

Use the Form_Resize event.  The following is an example:

Private Sub Form_Resize()
If Me.WindowState <> 1 Then
  ' TDBGrid1 is a top aligned data grid being resized to fit the
  'form. The bottom of the grid is always 3.5 * the height of the
  'close button from the bottom... (There is also a datacontrol
  'aligned to the bottom of this form.)
  TDBGrid1.Height = Me.Height - (cmdClose.Height * 3.5)
  ' cmdClose is always on the right corner just below the grid
  'and just above the datacontrol...the same distance from the
  'right side of the form.
  cmdClose.Left = Me.Width - 1500
  cmdClose.Top = Me.Height - 1200
  ' cmdFrmDtl is always on the left but its relative horizontal
  'position never changes
  cmdFrmDtl.Top = Me.Height - 1200
  'cmdTree is to be centered on the form and level with the
  'other buttons
  cmdTree.Top = Me.Height - 1200
  cmdTree.Left = (Me.Width / 2) - (cmdTree.Width / 2)
End If
End Sub

First, Make sure the window is not being minimized as you will get an error moving things around on minimized forms.
vbNormal      0      (Default) Normal.
VbMinimized      1      Minimized (minimized to an icon)
VbMaximized      2      Maximized (enlarged to maximum size)

Adjust your controls proportionately to the form's Width & Height properties (Me refers to the current form)
To adjust the a text box width as you need just do something like this:
text1.width = Me.Width - 150
Where you have 75 of border on the left and 75 of border on the right... This way you always have a proportionate box.

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question