I do not know in designing forms I set objects in center of and set the properity to auto center, but in form view when maximize the form objects go to the top left of the form, Can anyone help me,Please?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Access forms have an On Resize
event where you can adjust the horizontal location of various controls on the form by manipulating their .Left
properties based on the .Width
properties of the form itself.
For example, say I have a form with a Command Button named Button0
. To keep it (more or less) centered horizontally when the window is resized, I can use the following code in the Form's On Resize
event:
Private Sub Form_Resize()
'' adjust the horizontal position of the Command0 button
Me.Command0.Left = (Me.InsideWidth - Me.Command0.Width) / 2
End Sub
Note:
For Access 2007 and later you could also use control layouts. For details on how to use them for centering, see the related question here:
How to Dynamically keep controls centered (relative position) on an MS Access form?