Solved

Form positioning

Posted on 2002-03-26
5
173 Views
Last Modified: 2010-05-02
I have a form with a datagrid on it, I would like to open another form and position the upper left corner in the same spot of the datagrids upper left corner.

Thanks
0
Comment
Question by:mrf1001
  • 3
5 Comments
 
LVL 22

Accepted Solution

by:
rspahitz earned 100 total points
ID: 6897957
' code somewhere in form1
Load Form2
'...
Form2.Show

' code in Form2
Private Sub Form_Load()
  Me.Move Form1.Left + (Form1.Width - Form1.ScaleWidth) / 2 + Form1.txtEntireText.Left, Form1.Top + (Form1.Height - Form1.ScaleHeight - (Form1.Width - Form1.ScaleWidth) / 2) + Form1.txtEntireText.Top
End Sub
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6897966
Basically, move the new form to the location of the previous form, then shift it over to the right of the form's border (*) then shift it the distance of the desired control (in your case the datagrid.)

Do the same with the top, except that the height of the top form border is the form's height minus the scaleheight minus the bottom border.  But the bottom border cannot be captured directly so you have to take 1/2 of the side border (which was also calculated for the width.)

(*) Form's border= 1/2 the difference between the form's width and the form's workarea width (aka scalewidth)
0
 
LVL 1

Expert Comment

by:kavithag
ID: 6898678
Create the II FORM dynamically through code and place the db grid and on it and position it as the first form
0
 

Author Comment

by:mrf1001
ID: 6899879
Works great with some minor modification

Thanks
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6899883
Great!  Glad to help.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now