?
Solved

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

Posted on 2007-12-05
7
Medium Priority
?
912 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
[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
  • 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 300 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 500 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 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

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