473,385 Members | 1,400 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,385 software developers and data experts.

Problem positioning a form

Hi, would someone be able to verify this crazy behaviour/

1. Launch VS.Net 2003, create a new project with a "Form1"
2. Add "Button1" to the form.
3. Paste in the code below.

When I move the cursor over the button & leave it there a while (for
the hover event to fire), the form displays. Note the position. I move
the cursor away from the button, then back onto it to fire the hover
event again, and for the second and all subsequent times, the form is
positioned in a different place to originally. So why it is not
displayed at 100,100 the first time, but for the second, third, fourth
etc?

Thank you (again)
Colin

Public Class Form1
Inherits System.Windows.Forms.Form

'Windows Form Designer generated code <start>
'
' <snip>
'
'Windows Form Designer generated code <end>
Dim frm As New Form

Private Sub hoverDisplayNewForm(ByVal sender As Object, _
ByVal e As System.EventArgs)
frm.Location = New Point(100, 100)
frm.Show()
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
AddHandler Button1.MouseHover, AddressOf hoverDisplayNewForm
frm.Size = New Size(50, 50)
End Sub

End Class
Nov 20 '05 #1
3 928
Colin,
Because the default for start position is
FormStartPosition.WindowsDefaultLocation which means that Windows itself
controls where the form will appear, if you want the form in a specific
location set the StartPostion to like FormStartPostion.Manual.

Hope this helps
Jay

"Colin McGuire" <co***********@lycos.co.uk> wrote in message
news:ab**************************@posting.google.c om...
Hi, would someone be able to verify this crazy behaviour/

1. Launch VS.Net 2003, create a new project with a "Form1"
2. Add "Button1" to the form.
3. Paste in the code below.

When I move the cursor over the button & leave it there a while (for
the hover event to fire), the form displays. Note the position. I move
the cursor away from the button, then back onto it to fire the hover
event again, and for the second and all subsequent times, the form is
positioned in a different place to originally. So why it is not
displayed at 100,100 the first time, but for the second, third, fourth
etc?

Thank you (again)
Colin

Public Class Form1
Inherits System.Windows.Forms.Form

'Windows Form Designer generated code <start>
'
' <snip>
'
'Windows Form Designer generated code <end>
Dim frm As New Form

Private Sub hoverDisplayNewForm(ByVal sender As Object, _
ByVal e As System.EventArgs)
frm.Location = New Point(100, 100)
frm.Show()
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
AddHandler Button1.MouseHover, AddressOf hoverDisplayNewForm
frm.Size = New Size(50, 50)
End Sub

End Class

Nov 20 '05 #2
Cor
Hi Colin,
Or in addition to Jay B.
Private Sub hoverDisplayNewForm(ByVal sender As Object, _
ByVal e As System.EventArgs)
frm.Location = New Point(100, 100)
frm.Show()
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
frm.Location = New Point(100, 100)
(Or get that position from the registry or a config file, and if it is from
the registry make a default or whatever, but test it that it exist the first
time)
AddHandler Button1.MouseHover, AddressOf hoverDisplayNewForm
frm.Size = New Size(50, 50)
End Sub

End Class

Nov 20 '05 #3
Jay/Cor, thank you. Yes - this makes sense.
Colin
Nov 20 '05 #4

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

Similar topics

2
by: Dariusz | last post by:
I am trying out a fully CSS-P layout (first time with floats) and am having problems with getting certain DIV's from displaying properly - or rather - they are being completely ignored. Below is...
9
by: | last post by:
hi everyone, i was hoping someone could help me. the code below - in IE the menu options (text) are a couple of pixels too low and i cant move them up, and the form boxes are ok. in mozilla the...
7
by: Griff Miller | last post by:
Please see http://home.houston.rr.com/gmiller15/css/vertprob.html . In mozilla 1.6/1.7 it looks the way I want it, with a thin separation between the two boxes. In IE6, the two boxes touch, which...
8
by: chrisoftoday | last post by:
Hi, I'm having trouble with some white space that's appearing in my table. I can't seem to spot the problem, it'd be great if someone could help. The HTML code (ignore the PHP, it shouldn't be...
1
by: Hamed | last post by:
Hello I have a question about CHILD forms in an MDI form. How can I have a neat positioning of child windows in an MDI form? When I open a new child window in my MDI form it is opened in a...
2
by: nino9stars | last post by:
Hello, I have just started messing with absolute positioning on webpages, and it definitely let's you do some creative things. Well, after much searching and help, I got the images I was using...
2
by: TheCruelPanda | last post by:
Hey there. My name is Rowan, and it's been three weeks since I last used tables for an HTML design. Okay, I'm rather new to CSS and I have a big positioning problem here. It might not be a...
7
by: =?Utf-8?B?QW50?= | last post by:
Hi, If I place a button on either a Web form or an HTML form, when I run the page in a browser, the button stretches right across the screen. This happens with our Enterprise Visual Studio at work...
1
by: mohammadtaha | last post by:
Hi, I am using CSS to position objects (<SPAN> and <DIV> tags) on my webpage, which is working great on regular computer monitors, when I view the same page on a wide screen laptop monitor,...
1
by: kt | last post by:
Hi, I need to adjust the positioning of some controls at run time depending on the visibility of some panels. I am hiding and showing panels at a button click and need to adjust the positioning of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.