I need to know how do i locate a form window on custom location at the desktop:
At application start.


Screen: http://img707.imageshack.us/img707/5653/56465ytyt.png

Other question: is there any idea to solve the design bugs on other Pcs?

P.S Im so newbie at VB.NET x)

Are you talking about choosing where the form loads from? If so, you can do this by clicking on the form and choosing the location via the Properties Menu. Just scroll down until you see the option StartPosition and then Choose Manual. Then add the following code to the Form1_Load event:

Dim x As Integer
    Dim y As Integer
    x = Screen.PrimaryScreen.WorkingArea.Width
    y = Screen.PrimaryScreen.WorkingArea.Height - Me.Height

    Do Until x = Screen.PrimaryScreen.WorkingArea.Width - Me.Width
        x = x - 1
        Me.Location = New Point(x, y)

This will start the application from the bottom right corner.

Hope this helps :)

commented: nice :) +12

The code I have provided above will start the app on pretty much any screen resolution in the bottom right. If you want to start the app from the top left you can use this code:

Me.Location = New Point(0, 0)

What this is doing is setting the location from the points you define. The first 0 is how many pixels from the left you want the app to start from. The second 0 is how many pixels from the top you want the app to start from. So, if you have the screen resolution of 1366x768 (Standard for all 15.6" monitors) and you want the app to start in the bottom left, you would use the following code:

Me.Location = New Point(0, 768 - Me.Height)

The reason I added "- Me.Height" is because if you just have 768 it will start 768 from the top which will make the app pretty much invisible. So, adding that code does the math for you without you having to take the height of your app and subtracting it manually.

I hope I didn't lose you through this small tutorial and I hope you learned that you can pretty much set the location anywhere you would like just by a simple code.

P.S. - The most practical code to use is the first code given in my post above as it works with all screen resolutions.

I was messing with the codes a little bit and came up with a very effective way to choose the position with all resolutions.

Bottom Left:

Me.Location = New Point(0, Screen.PrimaryScreen.WorkingArea.Height - Me.Height)

Bottom Right:

Me.Location = New Point(Screen.PrimaryScreen.WorkingArea.Width - Me.Width, Screen.PrimaryScreen.WorkingArea.Height - Me.Height)

Top Left:

Me.Location = New Point(0, 0)

Top Right:

Me.Location = New Point(Screen.PrimaryScreen.WorkingArea.Width - Me.Width, 0)

Hope you learned something because I know I did. ;)

If it wasn't for this post, I would have never attempted to choose my location but you gave me a reason to :)

thanks bro, well work fine :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.