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

Resizing Form and Controls

79
Hello,

I am want to Resize my form and form controls based on the users resolution.

For example :- i am making this application in 1024x768. it obviously works and looks well too me but when my user runs this application on his pc it looks horrible and wierd because his Resolution is 800x600.

I found a snippet on this forum to resize the window but that just isn't what i'm looking for - i want the controls and form both to resize depending on the user resolution. Like if the user has a 800x600 and the app was made with 1024x768 it should automatically resize the form and its form controls to fit on the screen.

Could some one help me with this i am really lost :( in this form i also saw some one saying to use % sign to assign size to form and its elements but i tried this and it doesn't work :s it says its invalid.

I am using VB.net - Visual Studio 2005 - PLZ Help :(

Thank you,
Regards,
Sep 23 '08 #1
14 2320
Curtis Rutland
3,256 Expert 2GB
This is going to be difficult, because you want server code to respond to client conditions.

Some or all of this will need to be done in Javascript, like detecting the size of the window, and probably resizing the controls as well. We have a javascript forum that you can try for help on this.
Sep 23 '08 #2
Plater
7,872 Expert 4TB
Unless this is a windows application, in which case it *could* be much easier.
Although 800x600 should have gone away along time ago. I can't even MAKE my computers do that resolution anymore
Sep 23 '08 #3
Curtis Rutland
3,256 Expert 2GB
Good call Plater. I assumed that this was web based.
Sep 23 '08 #4
zubair1
79
Thanks for tips guys

But it isn't a Web Application


It a Windows Application sorry i wasnt very specific on the issue, its a windows app i'm not sure about there but currently here where i am many people are using this resolution.. i dont but still 800x600 is an example.

To more simple - i want my app to automatically resize the form size to fit the current resolution and that includes the form controls too :( i'm postive its possible since many other apps i seen have this feature.

I'm not sure how to accomplish this though :(

But you guys are pretty lucky :) having all those cool PCs and all the other technologies at your fingertips - when things become old there it arrives here :( i hope things get much more faster here soon :)

Thank you!
Regards
Sep 23 '08 #5
jg007
283 100+
a quick serach on this forum would have found -

http://bytes.com/forum/thread828652-...esolution.html

http://bytes.com/forum/thread799227-...esolution.html

http://bytes.com/forum/thread773049-...esolution.html

I haven't tried the code but it should give you somewhere to start
Sep 23 '08 #6
jg007
283 100+
not sure if this is any use but this resizes 3 buttons and moves them so that they line up on the right so I have posted it in case you can use some of it

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  3.  
  4.         Me.Location = New System.Drawing.Point(0, 0)
  5.  
  6.         Me.Size = New System.Drawing.Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height)
  7.  
  8.  
  9.         Dim tempx, tempy As Integer
  10.         Dim screenx, screeny As Integer
  11.         Dim tempo As System.Drawing.Point
  12.         tempo = New System.Drawing.Point(1, 1)
  13.  
  14.         For Each x As System.Windows.Forms.Button In Me.Controls
  15.  
  16.  
  17.  
  18.             tempx = x.Size.Width
  19.             tempy = x.Size.Height
  20.             screenx = Me.Size.Width / 100
  21.             screeny = Me.Size.Height / 100
  22.             tempx = tempx / 100
  23.             tempx = tempx * (screenx * 50)
  24.             tempy = tempy / 100
  25.             tempy = tempy * (screeny * 33)
  26.             x.Size = New System.Drawing.Size(tempx, tempy)
  27.  
  28.  
  29.  
  30.  
  31.         Next
  32.  
  33.         tempo = New System.Drawing.Point(1, 1)
  34.  
  35.         For Each x As System.Windows.Forms.Button In Me.Controls
  36.             x.Location = tempo
  37.             tempo = New System.Drawing.Point(x.Location.X, x.Location.Y + x.Height)
  38.  
  39.         Next
  40.  
  41.     End Sub
  42.  
  43.  
Sep 23 '08 #7
Kapps
16
One approach to this is to check out Screen.PrimaryScreen.Bounds.Height/Width. This will show you the total area, minus the task bar, of your monitor (resolution), or if you want just the form, you could just check out Height/Width. Upon resizing, you would have to check what the current height and width is, and then would have to just specify a constant value for the portion of the screen you want it to take, and find an event that's called every time this should change (in particular, ReSize).
Sep 23 '08 #8
Plater
7,872 Expert 4TB
I *think* if you build your controls with anchoring and such, much of the position-resizing will be automatic when you change the size of the form.
As for changing widget size, that might require some math.
Sep 24 '08 #9
zubair1
79
Hi,

Thanks for all the help and support guys :)

Thanks for the code jg007, really appreciate it. - i can't seem to get it to work in my app.

I also can't understand Anchor property :( it just says left / top / right / bottom.

I have 1 TAB, 2 Buttons, 2 Panel, 2 Picture Box, 1 MultiLine Textbox, 1 Progressbar :(
Sep 24 '08 #10
Plater
7,872 Expert 4TB
The anchor property "anchors" your widget to the selected edge (top, bottom, left, right)

So if you put a widget 10px from the top and 3px from the left and have it sized to be 3px from the right, if you set it to anchor to left,top,right. No matter how you resize the form, it will always be that amount of px from those edges.
Just play with it and you'll see.
Sep 24 '08 #11
joedeene
583 512MB
how about looking at this from microsoft ?

http://support.microsoft.com/kb/182070
Sep 24 '08 #12
Curtis Rutland
3,256 Expert 2GB
how about looking at this from microsoft ?

http://support.microsoft.com/kb/182070
Good article, but it looks to be for VB6, not VB.NET. Still, the logic may apply.
Sep 24 '08 #13
jg007
283 100+
Hi,

Thanks for all the help and support guys :)

Thanks for the code jg007, really appreciate it. - i can't seem to get it to work in my app.

I also can't understand Anchor property :( it just says left / top / right / bottom.

I have 1 TAB, 2 Buttons, 2 Panel, 2 Picture Box, 1 MultiLine Textbox, 1 Progressbar :(
the code was more of an example and should work if you create a new application with 3x buttons then just drop the code into one of them or the form load

I 'think' that resize code will be something like that and will just require some playing to get the maths right, at the moment my code just splits 3 buttons between the screen height making them each 33% of it and 50% the width but you could have a set of variables with the Value for 1% of the prefered size then just resize all the controls to this scaled to the current screen

sorry if that is a bit unclear and if I can I will work out some code then post it .
Sep 24 '08 #14
zubair1
79
Thanks for all the support :)

I will try to do more inDepth into Anchors, Platter :) thanks for pointing that out by reading it it seems very cool and just what i need but as you said i will have to play around with it for awhile.

i also came across a third-party library from Softgroup .NET Form Resizer

i'm thinking of using that too, not exactly sure yet though (it seems to be alittle slow - its not exactly how all the other normal applications resize).
Sep 26 '08 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Tony | last post by:
Derived Forms resizing in dotnet. (Fix) Problem: If you have a form base class: public frmBase : System.Windows.Forms { public frmBase { // DefaultFormFont is new Font("Tahoma", 10);
11
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that...
1
by: Nikhil Patel | last post by:
Hi all, I dynamically create new controls and display them on the form. My problem is that the user has to resize form manually to see controls whose location property points to a point outside...
2
by: Vaughn | last post by:
Where can I get information on automatic resizing of controls when the form changes size (eg. if I dynamically increase the size of my form, the listview inside should automatically increase in...
8
by: Chris | last post by:
Hi, In design mode I built some windows with some controls (e.g. listboxes, labels, chgeck boxes etc.) in it, and I did set the property for the window size is set to normal. Now, when I run...
12
by: Søren Reinke | last post by:
Hi there I have a little problem. How do i make sure that a graph is not redrawn while the form with the graph is being resized ? I have tried to add a mouse up/down event handler on the...
4
by: Thomas Richter | last post by:
Hi, I can't get of the black flicker when I resize my form. this = Mainform : System.Windows.Forms.Form If I set the size from 300 to 500 I see for ca 500ms some black areas. I try to solve it...
1
by: Benz. | last post by:
Hello all, I'm having a very strange problem. I've an MDI application with many child forms. In 1 of my Child forms (Say frmA), I've a few design time controls. The forms Autoscroll property is...
13
by: Martin Ho | last post by:
I know this must be trivial for many of you. But I am playing with this and can't figure it out. I have a form, on that form is one panel which has 3 textboxes, when I run my program and...
1
by: =?Utf-8?B?U3RldmUgUmFuZGFsbA==?= | last post by:
I have a form with a number of panel controls on it. I have overriden the paint event (of the panel controls) to provide custom painting. What I have done is to use the Paint event to paint the...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.