Solved

Form positioning

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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.
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…

739 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