如何在MS Access表单上动态创建控件? [英] How do you dynamically create controls on a MS Access form?

查看:81
本文介绍了如何在MS Access表单上动态创建控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在MS Access中编写调查(数据输入)表格.我需要在问题表格中的标签上动态显示问题表中的所有问题.每个问题标签还将带有一个组合框,该框将显示可能的答案.

I am writing a survey (data input) form in MS Access. I need to dynamically display all the questions in the questions table in labels on my form. Each of these question labels will also be accompanied by a combo box that will display possible answers.

如何动态地向表单添加标签?

How can I add labels to a form dynamically?

推荐答案

请参见 CreateControl方法.对于标签,将AcControlType枚举中的acLabel用作CreateControl的ControlType参数.

See the CreateControl Method. For a label, use acLabel from the AcControlType Enumeration as the ControlType parameter for CreateControl.

但是,这将变得更加复杂.除了创建标签控件之外,您还需要设置其标题,位置(顶部"和左侧"属性)和大小(宽度"和高度"属性).也许还有其他属性:字体名称;字体大小;字体粗细;等

However, this will get more complicated. In addition to creating the label control you will want to set its caption, position (Top and Left properties), and size (Width and Height properties). Perhaps other properties as well: Font Name; Font Size; Font Weight; etc.

结构化数据源可能更容易,因此每个问题和答案对都包含一行.然后使用2个控件以连续的形式显示这些行:问题的文本框;和答案的组合框.这样,您就不必为动态创建控件而烦恼了.

It could be easier to structure your data source so it contains a row for each question and answer pair. Then present those rows in a continuous form with 2 controls: a text box for the question; and the combo box for the answer. Then you wouldn't need to bother with creating controls dynamically.

这篇关于如何在MS Access表单上动态创建控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆