Window Form Location vb.net2005
-
I have a MDI WIndow with treeview on the left,listview on the right with a splitter separating them I want to open my other forms at a particular cordinate but its not working. i did something like this dim myForm as New Invoice myForm.left = listview.left myForm.top=listview.top myForm.show the form wasnt positioned at where iwant it to be pls help t.aransiola
-
I have a MDI WIndow with treeview on the left,listview on the right with a splitter separating them I want to open my other forms at a particular cordinate but its not working. i did something like this dim myForm as New Invoice myForm.left = listview.left myForm.top=listview.top myForm.show the form wasnt positioned at where iwant it to be pls help t.aransiola
You used the coordinates of the listview, which are relative to it's parent container, not the screen. So, the form being contained by nothing, used the coordinates relative to the desktop, not a window in your application.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
I have a MDI WIndow with treeview on the left,listview on the right with a splitter separating them I want to open my other forms at a particular cordinate but its not working. i did something like this dim myForm as New Invoice myForm.left = listview.left myForm.top=listview.top myForm.show the form wasnt positioned at where iwant it to be pls help t.aransiola
I ran into something simular last year and I think the problem was that you have to 'show' the form before setting the borders:
aransiola wrote:
dim myForm as New Invoice myForm.show myForm.left = listview.left myForm.top=listview.top
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistakes.
-
You used the coordinates of the listview, which are relative to it's parent container, not the screen. So, the form being contained by nothing, used the coordinates relative to the desktop, not a window in your application.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
pls assist with code snippet. The listview is on Mdimain window. Now i want the other windows cordinattes to be using the listview cordinates how do i get an object's reference cordinates in vb.net t.aransiola
aransiola wrote:
The listview is on Mdimain window. Now i want the other windows cordinattes to be using the listview cordinates
Since you haven't said anything about the parent container for this second form, I'm assuming you're not setting a parent window for the form. All you have to do is map the location of the ListView to Screen coordinates and use that result as the location for the new form.
Dim newLocation As Point = ListView1.PointToScreen(ListView1.Location) Dim newForm As New Form2() newForm.Location = newLocation
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
I ran into something simular last year and I think the problem was that you have to 'show' the form before setting the borders:
aransiola wrote:
dim myForm as New Invoice myForm.show myForm.left = listview.left myForm.top=listview.top
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistakes.
The code as shown below worked for non-modal window form but did not position modal window forms. even setting the cordinates before showing the window form dim myForm as New Invoice myForm.show myForm.left = listview.left myForm.top=listview.top any further discoveries to positioning modal forms will be appreciated. thanks thank u t.aransiola