Solved

Form positioning

Posted on 2002-03-26
5
188 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

696 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