Form and controls out of sync - vb.net

Hi so I have just noticed something very strange and I'm wondering if anyone else has had this issue and how to fix it.
Basically using visual studios 2010 on a windows 7 computer I have noticed that the locations of my controls on a form are out of sync with the form size itself.
For example: If I make a form and set its size to 500x500 and then place a control on the form like a button and set its size to the same and its location to 0,0 then the control is cut off by about 10 pixels or so. It happens on both my work and home computer so it isn't the computer and the values are the same at both runtime and design time. It seems as though the controls are being scaled differently than the form and I am not sure why.
Any ideas?

The form's size includes the border. Use the ClientSize property instead.

Related

Responsive Windows Form (VB.Net)

I have a VSTO Outlook add-in written in VB.net that has Windows Forms. Users with Font/text size scaling set to 100% has no issues in the Windows Form:
However if they change the font scale to something higher than 100%, things get messed up in the Windows form like below:
Do you know how can I make this form responds to font scaling settings and stay readable and viewable?
So what I have done so far to fix the issue:
Clear the font of the Windows form so that is resets back to the default font name and size
Set the ControlBox property of the Windows form to True

VBA Form.Move method (Access) - Not working for Split Forms

Form.Move Method is not working for Split Forms
In my MS Access 2016 database, I have a lot of forms that open in dialog mode. The main Access window has no tabs. The main window displays one form and sometimes changes sizes when going to a different main form. The dialog style forms popup relative to the main window.
I use the Form.Move method to position and resize the forms relative to the location of the Access Main Application Window. The Move method works great! However, the move method seems to do nothing for Split forms.
I have also tried docmd.movesize since it does move and size split forms. It also works great, except that, in my situation, docmd.movesize positions the form relative to the Main Monitor's Top-Left corner and cannot use negative numbers. By "Main Monitor" i mean the monitor that is setup as the Main Monitor in Windows display settings.
DoCmd.MoveSize( _Right_, _Down_, _Width_, _Height_ )
Some of the users of my database use 3 monitors. They use their laptop as their main monitor and have it position below their two bigger monitors. Any of the desktop real estate above their laptop has negative "Down" location values as a paramater for DoCmd.MoveSize to apply. The Form.Move method handles negative locations wonderfully, but it isn't working for my Split Forms. For me, the DoCmd.MoveSize causes an error when using negative values.
The "Right" value could also be negative when the main monitor is position between the two bigger monitors.
Here are my current form settings. I am pretty sure I have tried every combination.
Pop Up = No
Modal = No
Default View = Split Form
Auto Center = Yes
Auto Resize = No
Fit to Screen = Yes
Border Style = Sizeable
The forms are opened with this code which overrides some of the setting above.
DoCmd.OpenForm "frmWorkGroupList", , , , , acDialog
Form Size code
DoCmd.MoveSize xPosMax, yPosMax, vWidth, vHeight
Me.Move Left:=xPosMax, Top:=yShiftTwips, Width:=vWidth, Height:=vHeight
I have searched for a good solution for many hours and I have tried everything I can think of. The only solution I can find online was to re-create my forms into sub-forms inside of main forms to simulate a split form. I don't wan to do that. I want Split Forms to work if possible.
Currently I am using DoCmd.MoveSize with a check for negative values. If there are any negative values for x and/or y I move to a default x and y location that will land on the main monitor.
Are there any solutions that will Move/Size Split Forms to desktop locations that have negative "Down" location values?
Thank all of you in advance!
Buddy Martin

How to initiate the size of form in vb.net

If I run my program this is what I see
That's not the size of the form that I make. It seems that when I click run, windows set the size of the form as the size of any standard form that shows up.
The size of the form is similar to the size of a newly opened internet explorer.
If I set the form to be unresizeable the form is indeed unresizeable but it's initial size is determined by windows.
How do I set that the size of the form match the size of the form when I design the program?
You need to check a couple of properties of the form as a combination of these may affect the form size such as AutoScale, AutoSize, FormBorderStyle, WindowState. Also check for the DefaultSize, Size, Width, Height, MaximizedBounds and ClientSize properties.
You should also check the form events, particularly Load event, whether you are setting any of those properties in these events?
As another approach you can try fixing the form size in the Load event.
Assuming that you are using WinForms, try setting the form's StartPosition property to WindowsDefaultLocation, CenterScreen or Manual.

Visual Studio Form Designer changes layout of controls on open

I have a user control that looks like this in the designer:
However, when I close the designer and open it again, it looks like this:
The eight controls that have moved are text boxes and labels that are all set to Anchor Top, Right while all the other controls have different anchoring.
Does anyone have any idea what is causing this change of layout, and more importantly, how it can be prevented?
I also had the problem of changing the layout of my form every time by opening it in design mode.
The problem was the use of the tool "TableLayoutPanel".
By coincidence I found that changing the property "Dock" solved the problem.
Just set to another value and then undo this.
After this is seems to be solved. Don't ask me why!

fix form size in visual studio

I am trying to design a web form in visual basic and i have a problem.I put all the elements(buttons, labels etc) in the place i want.When i run the form i have the option to maximize the screen of the form and when i do this,a blank space appears in the form where there are no elements and all my elements are shown to the left upper side of the form. I can't see that blank space when i am designing the form. Could you help me how to fix the fix the size?
I tried autosize,autoscroll and size properties but i didn't fix the problem.
You don't specify whether it's VB6 or VB.Net but for once, it doesn't matter much.
Look at the form property BorderStyle, and change it to one of the "fixed" options.
VB6 documentation
VB.Net documentation