PrintPreviewDialog.AcceptButton PrintPreviewDialog.AcceptButton PrintPreviewDialog.AcceptButton PrintPreviewDialog.AcceptButton Property

定义

获取或设置当用户按 Enter 键时所单击的窗体上的按钮。Gets or sets the button on the form that is clicked when the user presses the ENTER key.

public:
 property System::Windows::Forms::IButtonControl ^ AcceptButton { System::Windows::Forms::IButtonControl ^ get(); void set(System::Windows::Forms::IButtonControl ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.IButtonControl AcceptButton { get; set; }
member this.AcceptButton : System.Windows.Forms.IButtonControl with get, set
Public Property AcceptButton As IButtonControl

属性值

IButtonControl,表示要用作窗体的“接受”按钮的按钮。An IButtonControl that represents the button to use as the accept button for the form.

注解

此属性与此类无关。This property is not relevant for this class.

使用此属性可以指定用户在应用程序中按 ENTER 键时发生的默认操作。This property allows you to designate a default action that occurs when the user presses the ENTER key in your application. 分配给此属性的按钮必须IButtonControl是当前窗体上的, 或者位于当前窗体上的容器中。The button assigned to this property must be an IButtonControl that is on the current form or located within a container on the current form.

例如, 您可以使用此属性, 以允许用户在简单的窗体完成时按 ENTER 键, 而不是使用鼠标手动单击 "接受" 按钮。You can use this property, for example, to allow the user to quickly navigate a simple form by allowing them to press the ENTER key when they are finished instead of manually clicking the accept button with their mouse.

如果窗体上当前选定的控件截获 ENTER 键并对其进行处理, 则可能不会激活 "接受" 按钮。The accept button might not be activated if the currently selected control on the form intercepts the ENTER key and processes it. 例如, 如果选择此选项, 则在控件中插入新的行字符时, 多行文本框控件允许按 ENTER 键。For example, a multiline text box control allows the ENTER key to be pressed when it is selected to insert a new line character in the control.

适用于

另请参阅