473,396 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Moving Forms

Hi,

Im fairly new to VB.NET and am hoping someone can help me with what is
probably a simple problem.

I have an MDI app, when I open a child form, I want it centered to the
parent. So I put some code in the FormLoad procedure which works out
the centre of the screen and moves the child appropraitely.

This is pretty much the code I have:

MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()

The problem is that when this window opens, you can actually see the
form move. It seems that if i remove the call to refresh_vehiclelist
that the problem isnt as bad, but is still visible. This procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a current
Core 2 Duo system.

My question is, is there anyway to hide the form before moving it (I
tried the Hide method but it didnt move) so that the user can not see
the form moving every time they open it?

Many thanks in advance!

Brad.

Oct 10 '06 #1
14 1986
Just put the code under Sub New After the InitializeCompenent call. As
for the answer to the me.hide question, you can just set me.visible =
false.

Thanks,

Seth Rowe
bw*****@gmail.com wrote:
Hi,

Im fairly new to VB.NET and am hoping someone can help me with what is
probably a simple problem.

I have an MDI app, when I open a child form, I want it centered to the
parent. So I put some code in the FormLoad procedure which works out
the centre of the screen and moves the child appropraitely.

This is pretty much the code I have:

MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()

The problem is that when this window opens, you can actually see the
form move. It seems that if i remove the call to refresh_vehiclelist
that the problem isnt as bad, but is still visible. This procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a current
Core 2 Duo system.

My question is, is there anyway to hide the form before moving it (I
tried the Hide method but it didnt move) so that the user can not see
the form moving every time they open it?

Many thanks in advance!

Brad.
Oct 10 '06 #2
What about using the StartPosition property before you actually open the
form? Will that help?

Dim frm As New Form2

frm.StartPosition = FormStartPosition.CenterParent

frm.Visible = True
Steve

<bw*****@gmail.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.com...
Hi,

Im fairly new to VB.NET and am hoping someone can help me with what is
probably a simple problem.

I have an MDI app, when I open a child form, I want it centered to the
parent. So I put some code in the FormLoad procedure which works out
the centre of the screen and moves the child appropraitely.

This is pretty much the code I have:

MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()

The problem is that when this window opens, you can actually see the
form move. It seems that if i remove the call to refresh_vehiclelist
that the problem isnt as bad, but is still visible. This procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a current
Core 2 Duo system.

My question is, is there anyway to hide the form before moving it (I
tried the Hide method but it didnt move) so that the user can not see
the form moving every time they open it?

Many thanks in advance!

Brad.

Oct 10 '06 #3
What about using the StartPosition property before you actually open the
form? Will that help?

Dim frm As New Form2

frm.StartPosition = FormStartPosition.CenterParent

frm.Visible = True
Steve

<bw*****@gmail.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.com...
Hi,

Im fairly new to VB.NET and am hoping someone can help me with what is
probably a simple problem.

I have an MDI app, when I open a child form, I want it centered to the
parent. So I put some code in the FormLoad procedure which works out
the centre of the screen and moves the child appropraitely.

This is pretty much the code I have:

MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()

The problem is that when this window opens, you can actually see the
form move. It seems that if i remove the call to refresh_vehiclelist
that the problem isnt as bad, but is still visible. This procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a current
Core 2 Duo system.

My question is, is there anyway to hide the form before moving it (I
tried the Hide method but it didnt move) so that the user can not see
the form moving every time they open it?

Many thanks in advance!

Brad.


Oct 10 '06 #4
I believe that mdi child forms ignore the StartPosition property. Not
100% sure however.

Thanks,

Seth Rowe
Steve Long wrote:
What about using the StartPosition property before you actually open the
form? Will that help?

Dim frm As New Form2

frm.StartPosition = FormStartPosition.CenterParent

frm.Visible = True
Steve

<bw*****@gmail.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.com...
Hi,

Im fairly new to VB.NET and am hoping someone can help me with what is
probably a simple problem.

I have an MDI app, when I open a child form, I want it centered to the
parent. So I put some code in the FormLoad procedure which works out
the centre of the screen and moves the child appropraitely.

This is pretty much the code I have:

MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()

The problem is that when this window opens, you can actually see the
form move. It seems that if i remove the call to refresh_vehiclelist
that the problem isnt as bad, but is still visible. This procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a current
Core 2 Duo system.

My question is, is there anyway to hide the form before moving it (I
tried the Hide method but it didnt move) so that the user can not see
the form moving every time they open it?

Many thanks in advance!

Brad.
Oct 10 '06 #5
Hi Seth, thanks for your help, but as i'm fairly new to vb.net, can you
please explain a little further what you mean by putting the code under
"Sub New" and where the InitializeComponent call is?

I have tried some other suggestions here but it seems unless the form
is visible (not hidden) setting the Top and Left positions have no
effect and the form opens in the top left corner of the MDI Parent.

Thanks!
rowe_newsgroups wrote:
Just put the code under Sub New After the InitializeCompenent call. As
for the answer to the me.hide question, you can just set me.visible =
false.

Thanks,

Seth Rowe
bw*****@gmail.com wrote:
Hi,

Im fairly new to VB.NET and am hoping someone can help me with what is
probably a simple problem.

I have an MDI app, when I open a child form, I want it centered to the
parent. So I put some code in the FormLoad procedure which works out
the centre of the screen and moves the child appropraitely.

This is pretty much the code I have:

MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()

The problem is that when this window opens, you can actually see the
form move. It seems that if i remove the call to refresh_vehiclelist
that the problem isnt as bad, but is still visible. This procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a current
Core 2 Duo system.

My question is, is there anyway to hide the form before moving it (I
tried the Hide method but it didnt move) so that the user can not see
the form moving every time they open it?

Many thanks in advance!

Brad.
Oct 11 '06 #6
Sub New() is the construnctor for for an object - in this case the
form. If you type in "Sub New" and press enter the ide will change that
to the following:

Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub

The InitializeComponent is a method that contains the code generated by
the designer. Any time you add a control or change it's properties it
is writen to this method. Generally, you want this call to occur before
anything else happens, that why I (and the comment line in the sub)
tell you to place the code after this call. Unfortunately, mdichildren
apperantly ignore changes to the size properties here also, so my
advice won't help. I'll do some research to find out why, or perhaps
someone else will shed some light on this.

Thanks,

Seth Rowe
bw*****@gmail.com wrote:
Hi Seth, thanks for your help, but as i'm fairly new to vb.net, can you
please explain a little further what you mean by putting the code under
"Sub New" and where the InitializeComponent call is?

I have tried some other suggestions here but it seems unless the form
is visible (not hidden) setting the Top and Left positions have no
effect and the form opens in the top left corner of the MDI Parent.

Thanks!
rowe_newsgroups wrote:
Just put the code under Sub New After the InitializeCompenent call. As
for the answer to the me.hide question, you can just set me.visible =
false.

Thanks,

Seth Rowe
bw*****@gmail.com wrote:
Hi,
>
Im fairly new to VB.NET and am hoping someone can help me with what is
probably a simple problem.
>
I have an MDI app, when I open a child form, I want it centered to the
parent. So I put some code in the FormLoad procedure which works out
the centre of the screen and moves the child appropraitely.
>
This is pretty much the code I have:
>
MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()
>
The problem is that when this window opens, you can actually see the
form move. It seems that if i remove the call to refresh_vehiclelist
that the problem isnt as bad, but is still visible. This procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a current
Core 2 Duo system.
>
My question is, is there anyway to hide the form before moving it (I
tried the Hide method but it didnt move) so that the user can not see
the form moving every time they open it?
>
Many thanks in advance!
>
Brad.
Oct 11 '06 #7
Brad, try this:
Dim frm As frmMDIChild1

Dim size As Size

size.Width = Me.Width / 2

size.Height = Me.Height / 2

frm = New frmMDIChild1

frm.MdiParent = Me ' this is the MDI parent

frm.StartPosition = FormStartPosition.Manual

frm.Left = 20

frm.Top = 20

frm.Size = size

'frm.StartPosition = FormStartPosition.CenterParent

frm.Show()

HTH

Steve

<bw*****@gmail.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.com...
Hi,

Im fairly new to VB.NET and am hoping someone can help me with what is
probably a simple problem.

I have an MDI app, when I open a child form, I want it centered to the
parent. So I put some code in the FormLoad procedure which works out
the centre of the screen and moves the child appropraitely.

This is pretty much the code I have:

MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()

The problem is that when this window opens, you can actually see the
form move. It seems that if i remove the call to refresh_vehiclelist
that the problem isnt as bad, but is still visible. This procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a current
Core 2 Duo system.

My question is, is there anyway to hide the form before moving it (I
tried the Hide method but it didnt move) so that the user can not see
the form moving every time they open it?

Many thanks in advance!

Brad.

Oct 11 '06 #8
Hi Steve thanks for helping however your code simply opens up an mdi
child in the top left, even if I try and center it. I also am trying to
center a form designed in the IDE... I don't uderstand why this is so
hard, surely what I am trying to do is not uncommon?

Thanks again for your help.
Steve Long wrote:
Brad, try this:
Dim frm As frmMDIChild1

Dim size As Size

size.Width = Me.Width / 2

size.Height = Me.Height / 2

frm = New frmMDIChild1

frm.MdiParent = Me ' this is the MDI parent

frm.StartPosition = FormStartPosition.Manual

frm.Left = 20

frm.Top = 20

frm.Size = size

'frm.StartPosition = FormStartPosition.CenterParent

frm.Show()

HTH

Steve

<bw*****@gmail.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.com...
Hi,

Im fairly new to VB.NET and am hoping someone can help me with what is
probably a simple problem.

I have an MDI app, when I open a child form, I want it centered to the
parent. So I put some code in the FormLoad procedure which works out
the centre of the screen and moves the child appropraitely.

This is pretty much the code I have:

MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()

The problem is that when this window opens, you can actually see the
form move. It seems that if i remove the call to refresh_vehiclelist
that the problem isnt as bad, but is still visible. This procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a current
Core 2 Duo system.

My question is, is there anyway to hide the form before moving it (I
tried the Hide method but it didnt move) so that the user can not see
the form moving every time they open it?

Many thanks in advance!

Brad.
Oct 11 '06 #9
Thanks Seth for explaining that, I understand now. Shame it is still
ignoring the properties. Appreciate any thing you come up with.

rowe_newsgroups wrote:
Sub New() is the construnctor for for an object - in this case the
form. If you type in "Sub New" and press enter the ide will change that
to the following:

Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub

The InitializeComponent is a method that contains the code generated by
the designer. Any time you add a control or change it's properties it
is writen to this method. Generally, you want this call to occur before
anything else happens, that why I (and the comment line in the sub)
tell you to place the code after this call. Unfortunately, mdichildren
apperantly ignore changes to the size properties here also, so my
advice won't help. I'll do some research to find out why, or perhaps
someone else will shed some light on this.

Thanks,

Seth Rowe
bw*****@gmail.com wrote:
Hi Seth, thanks for your help, but as i'm fairly new to vb.net, can you
please explain a little further what you mean by putting the code under
"Sub New" and where the InitializeComponent call is?

I have tried some other suggestions here but it seems unless the form
is visible (not hidden) setting the Top and Left positions have no
effect and the form opens in the top left corner of the MDI Parent.

Thanks!
rowe_newsgroups wrote:
Just put the code under Sub New After the InitializeCompenent call. As
for the answer to the me.hide question, you can just set me.visible =
false.
>
Thanks,
>
Seth Rowe
>
>
bw*****@gmail.com wrote:
Hi,

Im fairly new to VB.NET and am hoping someone can help me with what is
probably a simple problem.

I have an MDI app, when I open a child form, I want it centered to the
parent. So I put some code in the FormLoad procedure which works out
the centre of the screen and moves the child appropraitely.

This is pretty much the code I have:

MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()

The problem is that when this window opens, you can actually see the
form move. It seems that if i remove the call to refresh_vehiclelist
that the problem isnt as bad, but is still visible. This procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a current
Core 2 Duo system.

My question is, is there anyway to hide the form before moving it (I
tried the Hide method but it didnt move) so that the user can not see
the form moving every time they open it?

Many thanks in advance!

Brad.
Oct 11 '06 #10
Brad,
if you set the form's StartPosition to Manual, as I have in the code below,
you can then size the form and position it prior to opening it. I tried this
in a MDI application on my own system so I know that it works. However, if
you fail to set the StartPosition to Manual, it will mearly open up a form
in the top, left position. The whole trick is setting the StartPosition to
Manual first.

Steve

<bw*****@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi Steve thanks for helping however your code simply opens up an mdi
child in the top left, even if I try and center it. I also am trying to
center a form designed in the IDE... I don't uderstand why this is so
hard, surely what I am trying to do is not uncommon?

Thanks again for your help.
Steve Long wrote:
>Brad, try this:
Dim frm As frmMDIChild1

Dim size As Size

size.Width = Me.Width / 2

size.Height = Me.Height / 2

frm = New frmMDIChild1

frm.MdiParent = Me ' this is the MDI parent

frm.StartPosition = FormStartPosition.Manual

frm.Left = 20

frm.Top = 20

frm.Size = size

'frm.StartPosition = FormStartPosition.CenterParent

frm.Show()

HTH

Steve

<bw*****@gmail.comwrote in message
news:11**********************@c28g2000cwb.googleg roups.com...
Hi,

Im fairly new to VB.NET and am hoping someone can help me with what is
probably a simple problem.

I have an MDI app, when I open a child form, I want it centered to the
parent. So I put some code in the FormLoad procedure which works out
the centre of the screen and moves the child appropraitely.

This is pretty much the code I have:

MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()

The problem is that when this window opens, you can actually see the
form move. It seems that if i remove the call to refresh_vehiclelist
that the problem isnt as bad, but is still visible. This procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a current
Core 2 Duo system.

My question is, is there anyway to hide the form before moving it (I
tried the Hide method but it didnt move) so that the user can not see
the form moving every time they open it?

Many thanks in advance!

Brad.

Oct 11 '06 #11
Opps, I forgot to take out the line:
'frm.StartPosition = FormStartPosition.CenterParent
which was commented out anyway. Make sure you take that line out.

Steve

<bw*****@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi Steve thanks for helping however your code simply opens up an mdi
child in the top left, even if I try and center it. I also am trying to
center a form designed in the IDE... I don't uderstand why this is so
hard, surely what I am trying to do is not uncommon?

Thanks again for your help.
Steve Long wrote:
>Brad, try this:
Dim frm As frmMDIChild1

Dim size As Size

size.Width = Me.Width / 2

size.Height = Me.Height / 2

frm = New frmMDIChild1

frm.MdiParent = Me ' this is the MDI parent

frm.StartPosition = FormStartPosition.Manual

frm.Left = 20

frm.Top = 20

frm.Size = size

'frm.StartPosition = FormStartPosition.CenterParent

frm.Show()

HTH

Steve

<bw*****@gmail.comwrote in message
news:11**********************@c28g2000cwb.googleg roups.com...
Hi,

Im fairly new to VB.NET and am hoping someone can help me with what is
probably a simple problem.

I have an MDI app, when I open a child form, I want it centered to the
parent. So I put some code in the FormLoad procedure which works out
the centre of the screen and moves the child appropraitely.

This is pretty much the code I have:

MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()

The problem is that when this window opens, you can actually see the
form move. It seems that if i remove the call to refresh_vehiclelist
that the problem isnt as bad, but is still visible. This procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a current
Core 2 Duo system.

My question is, is there anyway to hide the form before moving it (I
tried the Hide method but it didnt move) so that the user can not see
the form moving every time they open it?

Many thanks in advance!

Brad.

Oct 11 '06 #12
I still haven't found an answer for "why", but for now you should just
call me.visible = false before you set the location of the child. Also,
the form shouldn't show in the form_load event unless you explicitly
tell it to (me.show(), me.bringtofront, etc). If you're using any of
these methods before setting the location, removing them may solve the
problem.

Sorry I'm not much more help,

Seth Rowe
bw*****@gmail.com wrote:
Thanks Seth for explaining that, I understand now. Shame it is still
ignoring the properties. Appreciate any thing you come up with.

rowe_newsgroups wrote:
Sub New() is the construnctor for for an object - in this case the
form. If you type in "Sub New" and press enter the ide will change that
to the following:

Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub

The InitializeComponent is a method that contains the code generated by
the designer. Any time you add a control or change it's properties it
is writen to this method. Generally, you want this call to occur before
anything else happens, that why I (and the comment line in the sub)
tell you to place the code after this call. Unfortunately, mdichildren
apperantly ignore changes to the size properties here also, so my
advice won't help. I'll do some research to find out why, or perhaps
someone else will shed some light on this.

Thanks,

Seth Rowe
bw*****@gmail.com wrote:
Hi Seth, thanks for your help, but as i'm fairly new to vb.net, can you
please explain a little further what you mean by putting the code under
"Sub New" and where the InitializeComponent call is?
>
I have tried some other suggestions here but it seems unless the form
is visible (not hidden) setting the Top and Left positions have no
effect and the form opens in the top left corner of the MDI Parent.
>
Thanks!
>
>
rowe_newsgroups wrote:
Just put the code under Sub New After the InitializeCompenent call. As
for the answer to the me.hide question, you can just set me.visible =
false.

Thanks,

Seth Rowe


bw*****@gmail.com wrote:
Hi,
>
Im fairly new to VB.NET and am hoping someone can help me with what is
probably a simple problem.
>
I have an MDI app, when I open a child form, I want it centered to the
parent. So I put some code in the FormLoad procedure which works out
the centre of the screen and moves the child appropraitely.
>
This is pretty much the code I have:
>
MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()
>
The problem is that when this window opens, you can actually see the
form move. It seems that if i remove the call to refresh_vehiclelist
that the problem isnt as bad, but is still visible. This procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a current
Core 2 Duo system.
>
My question is, is there anyway to hide the form before moving it (I
tried the Hide method but it didnt move) so that the user can not see
the form moving every time they open it?
>
Many thanks in advance!
>
Brad.
Oct 11 '06 #13
Hi Rowe,
I have run up against this before, in a non-MDI application and the only way
I could set a form's start up position to a custom location was to first set
the form's StartPosition property to manual before setting the x and y,
alternatively the location property, and then opening up the form. It works
in a MDI application as well, I just tested it.

BTW, loved your post about the Excel column hiding. It's better to teach a
man to fish and feed him for life than to give him a fish and feed him for a
day. I think you did that same type of thing with an Access question a few
days ago too. Nice.

Steve

"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
>I still haven't found an answer for "why", but for now you should just
call me.visible = false before you set the location of the child. Also,
the form shouldn't show in the form_load event unless you explicitly
tell it to (me.show(), me.bringtofront, etc). If you're using any of
these methods before setting the location, removing them may solve the
problem.

Sorry I'm not much more help,

Seth Rowe
bw*****@gmail.com wrote:
>Thanks Seth for explaining that, I understand now. Shame it is still
ignoring the properties. Appreciate any thing you come up with.

rowe_newsgroups wrote:
Sub New() is the construnctor for for an object - in this case the
form. If you type in "Sub New" and press enter the ide will change that
to the following:

Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub

The InitializeComponent is a method that contains the code generated by
the designer. Any time you add a control or change it's properties it
is writen to this method. Generally, you want this call to occur before
anything else happens, that why I (and the comment line in the sub)
tell you to place the code after this call. Unfortunately, mdichildren
apperantly ignore changes to the size properties here also, so my
advice won't help. I'll do some research to find out why, or perhaps
someone else will shed some light on this.

Thanks,

Seth Rowe
bw*****@gmail.com wrote:
Hi Seth, thanks for your help, but as i'm fairly new to vb.net, can
you
please explain a little further what you mean by putting the code
under
"Sub New" and where the InitializeComponent call is?

I have tried some other suggestions here but it seems unless the form
is visible (not hidden) setting the Top and Left positions have no
effect and the form opens in the top left corner of the MDI Parent.

Thanks!
rowe_newsgroups wrote:
Just put the code under Sub New After the InitializeCompenent call.
As
for the answer to the me.hide question, you can just set me.visible
=
false.

Thanks,

Seth Rowe
bw*****@gmail.com wrote:
Hi,
>
Im fairly new to VB.NET and am hoping someone can help me with
what is
probably a simple problem.
>
I have an MDI app, when I open a child form, I want it centered
to the
parent. So I put some code in the FormLoad procedure which works
out
the centre of the screen and moves the child appropraitely.
>
This is pretty much the code I have:
>
MdiParent = frmMain
Me.Top = ((frmMain.Height - Me.Height) / 2)
Me.Left = ((frmMain.Width - Me.Width) / 2)
Refresh_VehicleList()
>
The problem is that when this window opens, you can actually see
the
form move. It seems that if i remove the call to
refresh_vehiclelist
that the problem isnt as bad, but is still visible. This
procedure
makes SQL server calls so tends to pause briefly as it opens the
connection. Its not a speed issue with the hardware as its a
current
Core 2 Duo system.
>
My question is, is there anyway to hide the form before moving it
(I
tried the Hide method but it didnt move) so that the user can not
see
the form moving every time they open it?
>
Many thanks in advance!
>
Brad.

Oct 11 '06 #14
Steve Long wrote:
Brad,
if you set the form's StartPosition to Manual, as I have in the code below,
you can then size the form and position it prior to opening it. I tried this
in a MDI application on my own system so I know that it works. However, if
you fail to set the StartPosition to Manual, it will mearly open up a form
in the top, left position. The whole trick is setting the StartPosition to
Manual first.
I didn't know about that trick, I'll have to try that. :)

I've been dealing with this a different way. Following is a copy of my
response to another current thread. If nothing else, notice that I
take into account the possibility that the Child is wider/taller than
the Parent's client area, and never set the Top/Left less than zero;
which would hide part or all of the title bar:

-----

MDI children ignore the StartPosition property, as well as any other
attempt to set their position prior to .Show.

Put this in the Load event of every MDI child form you want centered:

CenterInParent(Me)

And this in a module:

Sub CenterInParent(ByRef frm As Object)
frm.Left = Higher((frm.Parent.ClientSize.Width - frm.Width) / 2, 0)

frm.Top = Higher((frm.Parent.ClientSize.Height - frm.Height) / 2,
0)
End Sub

Function Higher(ByRef x, ByRef y)
Higher = IIf(x y, x, y)
End Function

Oct 11 '06 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sam Sungshik Kong | last post by:
Hello! If I understand correctly, MouseMove event is triggered when the mouse moves (ie when point changes). I, however, found out that it's triggered even if the mouse is not moving. What I...
4
by: Ron Mexico | last post by:
Hi, Currently have an app that maintain that is written in VB6 and uses an access db (backend db only used as a data store not writing to the db). This app is a client app not server multi-teir...
1
by: siliconpi | last post by:
I'm looking for the simplest and cleanest way of having 10 buttons on a form, on which if I move my mouse over, a label's text changes as specified. I'm using Visual Basic .NET and I'm not too...
3
by: Just Me | last post by:
If I move the mouse cursor over a control and stop moving I get a MouseHover event. If I then move the cursor while staying within the control and then stop moving I do not get another...
2
by: Carl Gilbert | last post by:
Hi I have a math kinda problem where I'm trying to split some lines when two or more lines connect two shapes. The reason I am doing this is to make it clear that there are multiple lines...
3
by: AM Hulshoff | last post by:
Can someone tell me how I can move an object, in this case a listbox, over a form. The code below works, but not when the form is custom sized. It works perfectly when the form is maximized. And...
0
by: Nishanthmarathe | last post by:
Hi There!!! I am new to C# world. I am getting huge chunk of data from a 3rd party applications thru SOAP request and updating to my SQL Server. I cant implement Progress bar as there is no way...
8
by: Chris Asaipillai | last post by:
Hi there I have some questions for those experienced Visual Basic 6 programmers out there who have made the transition from VB6 to Vb.net. How long did it take you to learn at least the basic...
0
by: Ed Sonneveld | last post by:
I am moving some of my VS 2003 projects to VS 2005. In my base library there is a baseform that is inherited by most forms in my application. The baseform in the library contains a protected...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.