Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to reposition and resize controls at runtime?

Status
Not open for further replies.

Elena

Technical User
Oct 20, 2000
112
US
Hi,

I want to be able to create one or more frames at runtime based on user entry. Then I want to create one or more(usually more) command buttons and text boxes inside each frame based on information from a database. I have finally been able to figure out how to create it all, but now I need to be able to resize the frames and reposition them based on how many text boxes there are inside. And also, I need to be able to align everything so it looks right to the user. Is there a quick and dirty method, like an align method that will let me do that?

What I am doing now is trying to figure out the top and left properties of each command button and text box inside the frames. Then I guess I will have to go through and calculate the size of the frames and then position the frames. I'm thinking there must be an easier way. Any suggestions would be appreciated.

Thanks,
Elena
 
It not as simple as AlignAllTextboxes but not difficult you could do something like this. Obviously you'll want to take more into consideration but here's a start.

dim i As Integer
Dim intCol As Integer
intCol = 500
Dim intRowPerCol As Integer
intRowPerCol = 4
for i = 0 To Text1.count - 1
Text1(i).Left = Frame1.left + intCol
If i Mod 4 <> 0 Then
Text1(i).Top = Text1(i - 1).Top + 500
Else
Text1(i).Top = 500
End If
If i = intRowPerCol Then
intCol = intCol + 1500
End If
Next i
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top