what is the code for the program in vb.net that automatically adjust resolution based on the computer you are using?

i use WindowState.Maximize but only the background image adjust. my other stuf such as buttons, labels picturebox are not..can you help me guys? thanks

You have to find our the screen resolution, and based on that, you then adjust your image (resize it).
How to get screen resolution and resize image:

Dim width As Integer = Screen.PrimaryScreen.WorkingArea.Width
Dim height As Integer = Screen.PrimaryScreen.WorkingArea.Height

Dim image__1 As Image = Image.FromFile("filePathToImage")
Dim newImage As New Bitmap(width, height)
Using gr As Graphics = Graphics.FromImage(newImage)
	gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
	gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
	gr.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
	gr.DrawImage(image__1, New Rectangle(0, 0, width, height))
End Using
'now use newImage as background!

ahh.. ok thanks. that is for background image right? hmm.. but how about when it comes to buttons or labels.. i want then on ther fix location. in my computer with a resolution: 1440x900 their location are ok. but when i run my program on the other computer with different resolution they lost their fix location. and mes up my program design.. do you get what i want to do? hehe..
my program is on fullscreen..
that for the reply Mitja ^_^

for controls its more simple. Use ANCHOR property. By default, controls are set to top-left. Try to play with them a bit, and you will see what suits you most.

for controls its more simple. Use ANCHOR property. By default, controls are set to top-left. Try to play with them a bit, and you will see what suits you most.

ahmm. yea, anchor and dock.. . i'm working with it right now.thanks.
hmm another question is there any way for the form (or the windows) to make it resolution independent?

The ancor and dock methods might not always work.

That's when I resort the the following method:

'You will have to play with this to get everything right.
'This will automaticly move when the user resizes the window too.
Button1.Location.Y = Me.Width - 30 
'You can do the same for the X location.
Button1.Location.X = Me.Height - 10

Edited 4 Years Ago by Begginnerdev: n/a

hmm another question is there any way for the form (or the windows) to make it resolution independent?

It actually cannot be fully independent, it always has to addapt on the screen resolution (it has to based on it). You can have app. in 1290 x 1500 (or what ever), and if your screen is in 1680 X 1050, then you will have sliders inside your application to view all the content. And this is not something we want.
And one more thing: you cannot never know the resolution of user, right?
But something is deffenatelly sure, if your app. is on max 800x600, there is no worries - noone has lower resolution any longer :)

But to be sure, you always can do the check of the current resolution and addapt your application (and all the controls inside) based on the measurement of the screen.

Does this make any sence?
Hope it does :)
bye

I have error in
'Button1.Location.Y'
'Button1.Location.X'

Expression is a value and therefore cannot be the target of an assignment
:(

but thanks for the code

It actually cannot be fully independent, it always has to
But to be sure, you always can do the check of the current resolution and addapt your application (and all the controls inside) based on the measurement of the screen.

thanks for the suggestion/advice. hmm.. maybe i should make my program resolution to 1024x786 and force the other computer to change its resolution to 1024x786.. hmm hahaha..

thanks

Sorry, I typed it on the fly.

I forgot about the new Point.

Try this instead.

'For new Y position.
Button1.Location = New Point(Button1.Location.X, Me.Width - 30)
'For new X position
Button1.Location = new Point(Me.hieght - 100, Button1.Location.Y)

Edited 4 Years Ago by Begginnerdev: n/a

how to use newImage as background.
Dim image__1 As Image = Image.FromFile("filePathToImage") ????

if you got a lot of controls try to put them in panels so that instead of rescaling each control u can just move the panels around according to the resolution

This question has already been answered. Start a new discussion instead.