选项按钮。 "属性名" 属性(Outlook 窗体脚本)OptionButton.GroupName Property (Outlook Forms Script)

返回或设置一个 String 类型的值,该值标识一组互斥的 OptionButton 控件。Returns or sets a String that identifies a group of mutually exclusive OptionButton controls. 读/写。Read/write.

语法Syntax

表达式GroupNameexpression.GroupName

_表达式_一个代表选项按钮对象的变量。expression A variable that represents an OptionButton object.

备注Remarks

对组中的所有按钮使用相同的组名。Use the same GroupName for all buttons in the group. 默认设置是空字符串。The default setting is an empty string.

若要创建一组互斥的选项按钮控件,可以将按钮放在窗体上的**Frame** 中,也可以使用 "组名" 属性。To create a group of mutually exclusive OptionButton controls, you can put the buttons in a Frame on your form, or you can use the GroupName property. 由于以下原因,使用 GroupName 更为有效:GroupName is more efficient for the following reasons:

  • 不必为每个组包含一个 FrameYou do not have to include a Frame for each group. 由于未使用 Frame,减少了窗体中的控件数量,因此,提高了性能并减小了窗体大小。By not using a Frame, you reduce the number of controls on the form, and in turn, improve performance and reduce the size of the form.

  • 您将拥有更多的设计灵活性。You have more design flexibility. 如果使用 Frame 来创建组,所有按钮都必须位于 Frame 内。If you use a Frame to create the group, all the buttons must be inside the Frame. 如果需要多个组,每个组必须有一个框架If you want more than one group, you must have one Frame for each group. 然而,如果使用 GroupName 来创建组,组可以包含窗体上任何位置的选项按钮。However, if you use GroupName to create the group, the group can include option buttons anywhere on the form. 如果需要多个组,可为每个组指定唯一的名称;您仍可以将各个控件放置到窗体上的任何位置。If you want more than one group, specify a unique name for each group; you can still place the individual controls anywhere on the form.

  • 可以创建具有透明背景的按钮,这可改善窗体的视觉效果。You can create buttons with transparent backgrounds, which can improve the visual appearance of your form. Frame 不是透明控件。The Frame is not a transparent control.

无论您使用哪种方法来创建一组按钮,单击组中的一个按钮都会将同一组中的所有其他按钮设置为FalseRegardless of which method you use to create the group of buttons, clicking one button in a group sets all other buttons in the same group to False. 一个容器中具有相同的选项按钮的所有选项按钮都是相互排斥的。All option buttons with the same GroupName within a single container are mutually exclusive. 可以在两个容器中使用相同的组名,但这样做会创建两个组(每个容器中有一个),而不是创建一个包括两个容器的组。You can use the same group name in two containers, but doing so creates two groups (one in each container) rather than one group that includes both containers.

例如,假设窗体包含一些选项按钮和一个也包含选项按钮的 MultiPageFor example, assume your form includes some option buttons and a MultiPage that also includes option buttons. MultiPage 上的选项按钮属于一个组,窗体上的按钮属于另一个组。The option buttons on the MultiPage are one group and the buttons on the form are another group. 这两个组互不影响。The two groups do not affect each other. 更改 MultiPage 上的按钮设置不会影响窗体上的按钮。Changing the setting of a button on the MultiPage does not affect the buttons on the form.

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.