html control属性,ControlType 属性

可以在 Visual Basic 中使用ControlType确定或中的的类型。Byte型,可读/写。

expression.ControlType

expression必需。返回“应用于”列表中的一个对象的表达式。

设置

ControlType属性是用于指定控件类型的。

常量

控件

acBoundObjectFrame

acCheckBox

acComboBox

acCommandButton

acCustomControl

acImage

acLabel

acLine

acListBox

acObjectFrame

acOptionButton

acOptionGroup

acPage

acPageBreak

acRectangle

acSubform

acTabCtl

acTextBox

acToggleButton

注释ControlType或中设置,但能在所有视图中查看。

说明

ControlType属性不仅可以用于在代码中检查特定控件的类型,也可以对控件类型进行更改。例如,可以在窗体“设计”视图中将文本框的ControlType属性更改为acComboBox,使文本框变为组合框。

利用ControlType属性还可以根据特定的条件,改变窗体上相似控件的特征。例如,当不想让用户编辑文本框中已有的数据时,可以将所有文本框的属性设置为“平面”,并将窗体的属性设置为“否”。(SpecialEffect属性不影响是否可以编辑数据,它只提供一个控件行为已经更改的视觉提示。)

ControlType还用于在使用方法创建控件时指定控件类型。

示例

以下示例检查窗体上所有控件的ControlType属性。对所有标签和文本框控件,该过程切换其“SpecialEffect”属性。当标签的“特殊效果”属性设置为“凹陷”,且文本框的“特殊效果”属性设置为“普通”,AllowAdditions、AllowDeletions和AllowEdits属性均设置为True,则intCanEdit变量将切换为允许编辑基础数据。

Sub ToggleControl(frm As Form)

Dim ctl As Control

Dim intI As Integer, intCanEdit As Integer

Const conTransparent = 0

Const conWhite = 16777215

For Each ctl in frm.Controls

With ctl

Select Case .ControlType

Case acLabel

If .SpecialEffect = acEffectShadow Then

.SpecialEffect = acEffectNormal

.BorderStyle = conTransparent

intCanEdit = True

Else

.SpecialEffect = acEffectShadow

intCanEdit = False

End If

Case acTextBox

If .SpecialEffect = acEffectNormal Then

.SpecialEffect = acEffectSunken

.BackColor = conWhite

Else

.SpecialEffect = acEffectNormal

.BackColor = frm.Detail.BackColor

End If

End Select

End With

Next ctl

If intCanEdit = IFalse Then

With frm

.AllowAdditions = False

.AllowDeletions = False

.AllowEdits = False

End With

Else

With frm

.AllowAdditions = True

.AllowDeletions = True

.AllowEdits = True

End With

End If

End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值