Forms2OleControl class

Forms2OleControl class

Represents Microsoft Forms 2.0 OLE control. To learn more, visit the Working with Ole Objects documentation article.

Inheritance: Forms2OleControlOleControl

Properties

NameDescription
back_colorGets or sets a background color of the control. The default value depends on a type of the control.
captionGets or sets a Caption property of the control. Default value is an empty string.
child_nodesGets collection of immediate child controls.
enabledReturns True if control is in enabled state.
fore_colorGets or sets a foreground color of the control. The default value depends on a type of the control.
group_nameGets or sets a string that specifies a group of mutually exclusive controls. The default value is an empty string.
heightGets or sets a height of the control in points.
is_forms2_ole_controlReturns True if the control is a Forms2OleControl.
(Inherited from OleControl)
nameGets or sets name of the ActiveX control.
(Inherited from OleControl)
typeGets type of Forms 2.0 control.
valueGets underlying Value property which often represents control state. For example checked option button has ‘1’ value while unchecked has ‘0’. Default value is an empty string.
widthGets or sets a width of the control in points.

Methods

NameDescription

Examples

Shows how to verify the properties of an ActiveX control.

doc = aw.Document(file_name=MY_DIR + 'ActiveX controls.docx')
shape = doc.get_child(aw.NodeType.SHAPE, 0, True).as_shape()
ole_control = shape.ole_format.ole_control
self.assertEqual('CheckBox1', ole_control.name)
if ole_control.is_forms2_ole_control:
    check_box = ole_control.as_forms2_ole_control()
    self.assertEqual('First', check_box.caption)
    self.assertEqual('0', check_box.value)
    self.assertEqual(True, check_box.enabled)
    self.assertEqual(aw.drawing.ole.Forms2OleControlType.CHECK_BOX, check_box.type)
    self.assertEqual(None, check_box.child_nodes)
    self.assertEqual('', check_box.group_name)
    # Note, that you can't set GroupName for a Frame.
    check_box.group_name = 'Aspose group name'

See Also