how to auto center objects in a form in access 2007?

久未见 提交于 2020-01-04 09:25:47

问题


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?



来源:https://stackoverflow.com/questions/15805877/how-to-auto-center-objects-in-a-form-in-access-2007

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!