英文:
How can I trigger the mousedown event in a form with over 600 controls, including labels?
问题
我在MS Access中有一个表单,其中包含一个子表单。在这个子表单中,我有大量的控件 - 超过600个控件。其中一些是标签,但大多数是文本框。还有一些按钮。
我的意图是在单击这些控件之一时执行一个例程。在某些情况下,可以使用单击事件来实现这一点,但在其他情况下,只能考虑使用鼠标按下事件,因为每个控件都有不同的操作。因此,重要的是只使用鼠标按下事件。
所以我希望鼠标按下事件在表单中触发,无论按下哪个控件,否则我将不得不为每个控件编写一个例程。
我所遇到的问题是,当鼠标按下在表单的详细信息部分的空白区域内时,鼠标按下事件会被触发。但是当我单击标签时,事件不会发生。
从表单的角度来看,我如何在鼠标按住标签上时触发鼠标按下事件?谢谢你的帮助。
我尝试让鼠标按下事件在控件上清除,但在表单中使用鼠标按下属性。但是当我在表单上的空白区域上按鼠标时,事件会发生。但是当我在标签上按鼠标时,事件不会触发。
我尝试在控件的双击属性中填写一个虚拟过程,但这也没有起作用。
我期望在form_mousedown中的例程在按住标签时执行。但是这并没有发生。
英文:
I have a form in MS Access with a subform inside it. And in this subform, I have a bunch of controls - more than 600 controls. Some of them are labels but most are textboxes. Also, a few buttons.
My intention is to make a routine to be executed when one of these controls is clicked. In some cases this can be done with the click event but in other cases just the mousedown event can be considered because there are different actions for each control. So it is important to use just the mousedown event.
So I want the mousedown event to be triggered in the form, no matter what control is being pressed, otherwise I would have to write a routine for every control.
What I'm experiencing is that when the mouse is pressed inside a clear area of the detail section of the form, the event mousedown is triggered. But when I click over a label the event does not occur.
How can I trigger the event mousedown when the mouse is left pressed over a label from the form's perspective? Thank you for helping.
I have tried to let the mousedown event clear on the control but used the property mousedown in the form. But when I press the mouse over a clear space in the form, I have the event. But when I press the mouse over the label, I don't have the event triggered.
I have tried to fill the property double click in the control with a dummy procedure, but it also didn't work.
I expected the routine in form_mousedown to be executed when the label is left pressed. But it is not happening.
答案1
得分: 1
I'm here to help with Chinese translation. Here's the translated content you provided:
实现 WithEvents,你可以在我的文章中找到一个基本示例:
使用 WithEvents 创建 Windows Phone 颜色调色板和选择器
完整代码 - 太多内容无法在此列出 - 在我的 GitHub 仓库中查看:
英文:
Implement WithEvents, a basic example you can find in my article:
Create Windows Phone Colour Palette and Selector using WithEvents
Full code - too much to list here - at my repository at GitHub:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论