Question

Usually I write in C#, but today im fighting with VB.

I have code like this:

FormTest.Left = 1000

If FormTest.Visible Then
    FormTest.BringToFront()
Else
    FormTest.Show()
End If

It doesn't work.

When I moved part with setting Left property after Show() - it works.

If FormTest.Visible Then
    FormTest.BringToFront()
Else
    FormTest.Show()
End If

FormTest.Left = 1000

However, window shows at default location for a moment, then it "moves" to desired location. I want it to show in desired location.

In C# my "typical show window" procedure is diffrent - by using constructor, handling form instances manually etc. I have no idea how I should do this in VB. Please help.

Était-ce utile?

La solution

Try:

FormTest.Left = 1000
FormTest.Visible = True
FormTest.BringToFront()

And if you want the window to start at the position you want when you use .Show() then:

FormTest.StartPosition = FormStartPosition.Manual

With this way it will start on the position you specified from the beggining.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top