Solved

Form positioning

Posted on 2002-03-26
5
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

756 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