Solved

VB.Net - subsequent form's Center Parent not good enough

Posted on 2007-12-05
7
892 Views
Last Modified: 2012-06-21
I've got a popup form, show dialog, set to center parent.
Any easy way to move it up a notch or two (vertically)?

I like the positioning except that it's hanging over some text on the parent form, that I'd rather avoid hiding...
0
Comment
Question by:sirbounty
  • 3
  • 3
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20412970
The StartPosition is only a place to start when the form is first show.  If you want to move the form after it is shown, you can do that.  You will get a little jump, though, as the form is moved.  In order to keep from jumping, you could handle centering the child on the parent with your own code.

Bob
0
 
LVL 18

Accepted Solution

by:
jcoehoorn earned 75 total points
ID: 20412982
You can use manual, and set the form's left and top properties accordingly.  However, I think those properties work relative to the screen (I could be wrong in cases where you set the form's owner, I'd have to check that again to remember for sure), so you may need to use the parent form's PointToScreen() method to get your position set correctly relative to that form.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 20413089
I was thinking that I would have to do some calculations with the parent form's position, but wasn't sure if that was different with .Net....
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 125 total points
ID: 20413116
It is pretty much the same as with VB6, but you have some different properties for the Form to help you:  DisplayRectangle, ClientSize, and Bounds.

Bob
0
 
LVL 67

Author Comment

by:sirbounty
ID: 20413538
This seems to do it...does the logic look okay?

       Dim frmCal As New frmCalendar
       frmCal.StartPosition = FormStartPosition.Manual
       frmCal.Left = (Me.Left + (Me.Width / 2)) - frmCal.Width / 2
       frmCal.Top = ((Me.Top + (Me.Height / 2)) - frmCal.Height / 2) - 30 ' Subtract 30 twips to raise the top property of frmCal

And now that I've done it, I still want what I was thinking of adding earlier...some sort of border.  But that's another question.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 20413545
Based on your comments Bob, would it be better to set the bounds, rather than the top/left properties?
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 125 total points
ID: 20413572
That code looks good.  The Bounds property is good for getting the Top, Left, Width and Height, and probably wouldn't help much here.

Bob
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
passing a value with stream reader AFTER a ";" 3 41
Deserialize JSON array VB.Net problem 3 36
Code enhancement 5 12
Create XML 5 30
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

15 Experts available now in Live!

Get 1:1 Help Now