Form. Accept Button Свойство
Определение
Возвращает или задает кнопку в форме, которая срабатывает при нажатии клавиши ВВОД. Gets or sets the button on the form that is clicked when the user presses the ENTER key.
Значение свойства
Объект IButtonControl, представляющий кнопку, используемую в качестве кнопки «Принять» для формы. An IButtonControl that represents the button to use as the accept button for the form.
Примеры
В следующем примере создается новый экземпляр класса Form и вызывается ShowDialog метод для вывода формы в виде диалогового окна. The following example creates a new instance of a Form and calls the ShowDialog method to display the form as a dialog box. В примере задаются FormBorderStyle AcceptButton свойства,, CancelButton ,, MinimizeBox MaximizeBox и, StartPosition чтобы изменить внешний вид и функциональность формы на диалоговое окно. The example sets the FormBorderStyle, AcceptButton, CancelButton, MinimizeBox, MaximizeBox, and StartPosition properties to change the appearance and functionality of the form to a dialog box. В примере также используется Add метод Controls коллекции формы для добавления двух Button элементов управления. The example also uses the Add method of the form’s Controls collection to add two Button controls. В примере свойство используется HelpButton для вывода кнопки справки в строке заголовка диалогового окна. The example uses the HelpButton property to display a help button in the caption bar of the dialog box.
Комментарии
Это свойство позволяет назначить действие по умолчанию, выполняемое при нажатии пользователем клавиши Ввод в приложении. This property enables you to designate a default action to occur 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.
Это свойство позволяет пользователю быстро перемещаться по простой форме, позволяя им просто нажать клавишу ВВОД после их завершения вместо того, чтобы вручную нажать кнопку Accept с помощью мыши. You can use this property to allow the user to quickly navigate a simple form by allowing them to simply press the ENTER key when they are finished instead of manually clicking the accept button with their mouse.
Кнопка принять может быть не активирована, если текущий выбранный элемент управления в форме перехватывает клавишу ВВОД и обрабатывает его. The accept button might not be activated if the currently selected control on the form intercepts the ENTER key and processes it. Например, многострочный элемент управления «текстовое поле» позволяет нажать клавишу ВВОД, если он выбран для вставки символа новой строки в элемент управления. 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.
Form. Help Button Свойство
Определение
Возвращает или задает значение, указывающее, отображать ли кнопку «Справка» в заголовке формы. Gets or sets a value indicating whether a Help button should be displayed in the caption box of the form.
Значение свойства
Значение true для отображения кнопки «Справка» в заголовке формы; в противном случае — значение false . true to display a Help button in the form’s caption bar; otherwise, false . Значение по умолчанию — false . The default is false .
Примеры
В следующем примере создается новый экземпляр класса Form и вызывается ShowDialog метод для вывода формы в виде диалогового окна. The following example creates a new instance of a Form and calls the ShowDialog method to display the form as a dialog box. В примере задаются FormBorderStyle AcceptButton свойства,, CancelButton ,, MinimizeBox MaximizeBox и, StartPosition чтобы изменить внешний вид и функциональность формы на диалоговое окно. The example sets the FormBorderStyle, AcceptButton, CancelButton, MinimizeBox, MaximizeBox, and StartPosition properties to change the appearance and functionality of the form to a dialog box. В примере также используется Add метод Controls коллекции формы для добавления двух Button элементов управления. The example also uses the Add method of the form’s Controls collection to add two Button controls. В примере свойство используется HelpButton для вывода кнопки справки в строке заголовка диалогового окна. The example uses the HelpButton property to display a Help button in the caption bar of the dialog box.
Комментарии
Если для этого свойства задано значение true , в строке заголовка слева от кнопки Закрыть появляется маленькая кнопка с вопросительным знаком. When this property is set to true , a small button with a question mark appears in the caption bar to the left of the Close button. С помощью этой кнопки можно отобразить справку для приложения. You can use this button to display help for your application. Можно создать обработчик событий для HelpRequested события, чтобы отображать справочные сведения для пользователя при нажатии кнопки «Справка» формы. You can create an event handler for the HelpRequested event to display Help information to the user when the Help button of the form is clicked.
Чтобы отобразить кнопку справки, значение ControlBox Свойства формы должно быть true , значение по умолчанию. To display a Help button, the value of the form’s ControlBox property must be true , its default value. ControlBoxСвойство определяет, содержит ли правый верхний угол строки заголовка элементы управления, такие как кнопка развертывания, Кнопка сворачивания, кнопка справки и кнопка Закрыть. The ControlBox property determines whether the upper-right corner of the caption bar contains controls such as a maximize button, a minimize button, a help button, and a close button. Кроме того, необходимо также присвоить FormBorderStyle свойству формы значение FormBorderStyle.FixedSingle , FormBorderStyle.Sizable , FormBorderStyle.Fixed3D или FormBorderStyle.FixedDialog . In addition, you must also set the form’s FormBorderStyle property to FormBorderStyle.FixedSingle, FormBorderStyle.Sizable, FormBorderStyle.Fixed3D, or FormBorderStyle.FixedDialog.
Значение HelpButton свойства игнорируется, если отображаются кнопки развернуть или сворачивания . The value of the HelpButton property is ignored if the Maximize or Minimize buttons are shown.
Button Class
Definition
Represents a Windows button control.
Examples
The following code example creates a Button, sets its DialogResult property to DialogResult.OK, and adds it to a Form.
Remarks
A Button can be clicked by using the mouse, ENTER key, or SPACEBAR if the button has focus.
Set the AcceptButton or CancelButton property of a Form to allow users to click a button by pressing the ENTER or ESC keys even if the button does not have focus. This gives the form the behavior of a dialog box.
When you display a form using the ShowDialog method, you can use the DialogResult property of a button to specify the return value of ShowDialog.
You can change the button’s appearance. For example, to make it appear flat for a Web look, set the FlatStyle property to FlatStyle.Flat. The FlatStyle property can also be set to FlatStyle.Popup, which appears flat until the mouse pointer passes over the button; then the button takes on the standard Windows button appearance.
If the control that has focus accepts and processes the ENTER key press, the Button does not process it. For example, if a multiline TextBox or another button has focus, that control processes the ENTER key press instead of the accept button.
Constructors
Initializes a new instance of the Button class.
Properties
Gets the AccessibleObject assigned to the control.
Gets or sets the default action description of the control for use by accessibility client applications.
Gets or sets the description of the control used by accessibility client applications.
Gets or sets the name of the control used by accessibility client applications.
Gets or sets the accessible role of the control.
Gets or sets a value indicating whether the control can accept data that the user drags onto it.
Gets or sets the edges of the container to which a control is bound and determines how a control is resized with its parent.
Gets or sets a value indicating whether the ellipsis character (. ) appears at the right edge of the control, denoting that the control text extends beyond the specified length of the control.
Gets or sets where this control is scrolled to in ScrollControlIntoView(Control).
Gets or sets a value that indicates whether the control resizes based on its contents.
Gets or sets the mode by which the Button automatically resizes itself.
Gets or sets the background color of the control.
Gets or sets the background image displayed in the control.
Gets or sets the background image layout as defined in the ImageLayout enumeration.
Gets or sets the BindingContext for the control.
Gets the distance, in pixels, between the bottom edge of the control and the top edge of its container’s client area.
Gets or sets the size and location of the control including its nonclient elements, in pixels, relative to the parent control.
Gets a value indicating whether the ImeMode property can be set to an active value, to enable IME support.
Gets a value indicating whether the control can receive focus.
Determines if events can be raised on the control.
Gets a value indicating whether the control can be selected.
Gets or sets a value indicating whether the control has captured the mouse.
Gets or sets a value indicating whether the control causes validation to be performed on any controls that require validation when it receives focus.
Gets the rectangle that represents the client area of the control.
Gets or sets the height and width of the client area of the control.
Gets the name of the company or creator of the application containing the control.
Gets the IContainer that contains the Component.
Gets a value indicating whether the control, or one of its child controls, currently has the input focus.
Gets or sets the shortcut menu associated with the control.
Gets or sets the ContextMenuStrip associated with this control.
Gets the collection of controls contained within the control.
Gets a value indicating whether the control has been created.
Gets a CreateParams on the base class when creating a window.
Gets or sets the cursor that is displayed when the mouse pointer is over the control.
Gets the data bindings for the control.
Gets or sets the default cursor for the control.
Gets the default Input Method Editor (IME) mode supported by this control.
Gets the space, in pixels, that is specified by default between controls.
Gets the length and height, in pixels, that is specified as the default maximum size of a control.
Gets the length and height, in pixels, that is specified as the default minimum size of a control.
Gets the internal spacing, in pixels, of the contents of a control.
Gets the default size of the control.
Gets a value that indicates whether the Component is currently in design mode.
Gets the DPI value for the display device where the control is currently being displayed.
Gets or sets a value that is returned to the parent form when the button is clicked.
Gets the rectangle that represents the display area of the control.
Gets a value indicating whether the base Control class is in the process of disposing.
Gets or sets which control borders are docked to its parent control and determines how a control is resized with its parent.
Gets or sets a value indicating whether this control should redraw its surface using a secondary buffer to reduce or prevent flicker.
Gets or sets a value indicating whether the control can respond to user interaction.
Gets the list of event handlers that are attached to this Component.
Gets the appearance of the border and the colors used to indicate check state and mouse state.
Gets or sets the flat style appearance of the button control.
Gets a value indicating whether the control has input focus.
Gets or sets the font of the text displayed by the control.
Gets or sets the height of the font of the control.
Gets or sets the foreground color of the control.
Gets the window handle that the control is bound to.
Gets a value indicating whether the control contains one or more child controls.
Gets or sets the height of the control.
Gets or sets the image that is displayed on a button control.
Gets or sets the alignment of the image on the button control.
Gets or sets the image list index value of the image displayed on the button control.
Gets or sets the key accessor for the image in the ImageList.
Gets or sets the ImageList that contains the Image displayed on a button control.
Gets or sets the Input Method Editor (IME) mode supported by this control. This property is not relevant for this class.
Gets or sets the IME mode of a control.
Gets a value indicating whether the caller must call an invoke method when making method calls to the control because the caller is on a different thread than the one the control was created on.
Gets or sets a value indicating whether the control is visible to accessibility applications.
Gets or sets a value indicating whether the button control is the default button.
Gets a value indicating whether the control has been disposed of.
Gets a value indicating whether the control has a handle associated with it.
Gets a value indicating whether the control is mirrored.
Gets a cached instance of the control’s layout engine.
Gets or sets the distance, in pixels, between the left edge of the control and the left edge of its container’s client area.
Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.
Gets or sets the space between controls.
Gets or sets the size that is the upper limit that GetPreferredSize(Size) can specify.
Gets or sets the size that is the lower limit that GetPreferredSize(Size) can specify.
Gets or sets the name of the control.
Gets or sets padding within the control.
Gets or sets the parent container of the control.
Gets the size of a rectangular area into which the control can fit.
Gets the product name of the assembly containing the control.
Gets the version of the assembly containing the control.
Gets a value indicating whether the control is currently re-creating its handle.
Gets or sets the window region associated with the control.
This property is now obsolete.
Gets or sets a value indicating whether the control redraws itself when resized.
Gets the distance, in pixels, between the right edge of the control and the left edge of its container’s client area.
Gets or sets a value indicating whether control’s elements are aligned to support locales using right-to-left fonts.
Gets a value that determines the scaling of child controls.
Gets a value indicating whether the control should display focus rectangles.
Gets a value indicating whether the user interface is in the appropriate state to show or hide keyboard accelerators.
Gets or sets the site of the control.
Gets or sets the height and width of the control.
Gets or sets the tab order of the control within its container.
Gets or sets a value indicating whether the user can give the focus to this control using the TAB key.
Gets or sets the object that contains data about the control.
Gets or sets the text associated with this control.
Gets or sets the alignment of the text on the button control.
Gets or sets the position of text and image relative to each other.
Gets or sets the distance, in pixels, between the top edge of the control and the top edge of its container’s client area.
Gets the parent control that is not parented by another Windows Forms control. Typically, this is the outermost Form that the control is contained in.
Gets or sets a value that determines whether to use the Graphics class (GDI+) or the TextRenderer class (GDI) to render text.
Gets or sets a value indicating whether the first character that is preceded by an ampersand (&) is used as the mnemonic key of the control.
Gets or sets a value that determines if the background is drawn using visual styles, if supported.
Gets or sets a value indicating whether to use the wait cursor for the current control and all child controls.
Gets or sets a value indicating whether the control and all its child controls are displayed.
Gets or sets the width of the control.
This property is not relevant for this class.
Methods
Notifies the accessibility client applications of the specified AccessibleEvents for the specified child control.
Notifies the accessibility client applications of the specified AccessibleEvents for the specified child control .
Executes the specified delegate asynchronously on the thread that the control’s underlying handle was created on.
Executes the specified delegate asynchronously with the specified arguments, on the thread that the control’s underlying handle was created on.
Brings the control to the front of the z-order.
Retrieves a value indicating whether the specified control is a child of the control.
Creates a new accessibility object for the control.
Forces the creation of the visible control, including the creation of the handle and any visible child controls.
Creates a new instance of the control collection for the control.
Creates the Graphics for the control.
Creates a handle for the control.
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Sends the specified message to the default window procedure.
Destroys the handle associated with the control.
Releases all resources used by the Component.
Releases the unmanaged resources used by the ButtonBase and optionally releases the managed resources.
Begins a drag-and-drop operation.
Supports rendering to the specified bitmap.
Retrieves the return value of the asynchronous operation represented by the IAsyncResult passed.
Determines whether the specified object is equal to the current object.
Retrieves the form that the control is on.
Sets input focus to the control.
Retrieves the specified AccessibleObject.
Retrieves a value indicating how a control will behave when its AutoSize property is enabled.
Retrieves the child control that is located at the specified coordinates.
Retrieves the child control that is located at the specified coordinates, specifying whether to ignore child controls of a certain type.
Returns the next ContainerControl up the control’s chain of parent controls.
Serves as the default hash function.
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
Retrieves the next control forward or back in the tab order of child controls.
Retrieves the size of a rectangular area into which a control can be fitted.
Retrieves the bounds within which the control is scaled.
Returns an object that represents a service provided by the Component or by its Container.
Retrieves the value of the specified control style bit for the control.
Determines if the control is a top-level control.
Gets the Type of the current instance.
Conceals the control from the user.
Obtains a lifetime service object to control the lifetime policy for this instance.
Called after the control has been added to another container.
Invalidates the entire surface of the control and causes the control to be redrawn.
Invalidates a specific region of the control and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control.
Invalidates the specified region of the control (adds it to the control’s update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control.
Invalidates the specified region of the control (adds it to the control’s update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control.
Invalidates the specified region of the control (adds it to the control’s update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control.
Invalidates the specified region of the control (adds it to the control’s update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control.
Executes the specified delegate on the thread that owns the control’s underlying window handle.
Executes the specified delegate, on the thread that owns the control’s underlying window handle, with the specified list of arguments.
Raises the GotFocus event for the specified control.
Raises the LostFocus event for the specified control.
Raises the Click event for the specified control.
Raises the Paint event for the specified control.
Raises the PaintBackground event for the specified control.
Determines if a character is an input character that the control recognizes.
Determines whether the specified key is a regular input key or a special key that requires preprocessing.
Converts a Logical DPI value to its equivalent DeviceUnit DPI value.
Transforms a size from logical to device units by scaling it for the current DPI and rounding down to the nearest integer value for width and height.
Creates a shallow copy of the current Object.
Creates a shallow copy of the current MarshalByRefObject object.
Notifies the Button whether it is the default button so that it can adjust its appearance accordingly.
Raises the Invalidated event with a specified region of the control to invalidate.
Notifies the control of Windows messages.
Paints the background of the control.
Raises the BackColorChanged event when the BackColor property value of the control’s container changes.
Raises the BackgroundImageChanged event when the BackgroundImage property value of the control’s container changes.
Raises the BindingContextChanged event when the BindingContext property value of the control’s container changes.
Raises the EnabledChanged event when the Enabled property value of the control’s container changes.
Raises the FontChanged event when the Font property value of the control’s container changes.
Raises the ForeColorChanged event when the ForeColor property value of the control’s container changes.
Raises the RightToLeftChanged event when the RightToLeft property value of the control’s container changes.
Raises the VisibleChanged event when the Visible property value of the control’s container changes.
Generates a Click event for a button.
Forces the control to apply layout logic to all its child controls.
Forces the control to apply layout logic to all its child controls.
Computes the location of the specified screen point into client coordinates.
Computes the location of the specified client point into screen coordinates.
Preprocesses keyboard or input messages within the message loop before they are dispatched.
Preprocesses keyboard or input messages within the message loop before they are dispatched.
Processes a command key.
Processes a dialog character.
Processes a dialog key.
Processes a key message and generates the appropriate control events.
Processes a keyboard message.
Previews a keyboard message.
Processes a mnemonic character.
Raises the appropriate drag event.
Raises the appropriate key event.
Raises the appropriate mouse event.
Raises the appropriate paint event.
Forces the re-creation of the handle for the control.
Computes the size and location of the specified screen rectangle in client coordinates.
Computes the size and location of the specified client rectangle in screen coordinates.
Forces the control to invalidate its client area and immediately redraw itself and any child controls.
Provides constants for rescaling the Button control when a DPI change occurs.
Provides constants for rescaling the control when a DPI change occurs.
Resets the BackColor property to its default value.
Causes a control bound to the BindingSource to reread all the items in the list and refresh their displayed values.
Resets the Cursor property to its default value.
Resets the Button control to the state before it is pressed and redraws it.
Resets the Font property to its default value.
Resets the ForeColor property to its default value.
Resets the ImeMode property to its default value.
Resets the control to handle the MouseLeave event.
Resets the RightToLeft property to its default value.
Resets the Text property to its default value (Empty).
Resumes usual layout logic.
Resumes usual layout logic, optionally forcing an immediate layout of pending layout requests.
Converts the specified ContentAlignment to the appropriate ContentAlignment to support right-to-left text.
Converts the specified HorizontalAlignment to the appropriate HorizontalAlignment to support right-to-left text.
Converts the specified LeftRightAlignment to the appropriate LeftRightAlignment to support right-to-left text.
Converts the specified ContentAlignment to the appropriate ContentAlignment to support right-to-left text.
Converts the specified HorizontalAlignment to the appropriate HorizontalAlignment to support right-to-left text.
Converts the specified LeftRightAlignment to the appropriate LeftRightAlignment to support right-to-left text.
Scales the control and any child controls.
Scales the entire control and any child controls.
Scales the control and all child controls by the specified scaling factor.
Scales a logical bitmap value to it’s equivalent device unit value when a DPI change occurs.
Scales a control’s location, size, padding and margin.
This method is not relevant for this class.
Activates the control.
Activates a child control. Optionally specifies the direction in the tab order to select the control from.
Activates the next control.
Sends the control to the back of the z-order.
Sets a value indicating how a control will behave when its AutoSize property is enabled.
Sets the bounds of the control to the specified location and size.
Sets the specified bounds of the control to the specified location and size.
Performs the work of setting the specified bounds of this control.
Sets the size of the client area of the control.
Sets a specified ControlStyles flag to either true or false .
Sets the control as the top-level control.
Sets the control to the specified visible state.
Displays the control to the user.
Determines the size of the entire control from the height and width of its client area.
Temporarily suspends the layout logic for the control.
Returns a String containing the name of the Component, if any. This method should not be overridden.
Causes the control to redraw the invalidated regions within its client area.
Updates the bounds of the control with the current size and location.
Updates the bounds of the control with the specified size and location.
Updates the bounds of the control with the specified size, location, and client size.
Forces the assigned styles to be reapplied to the control.
Updates the control in its parent’s z-order.
Processes Windows messages.
Events
Occurs when the value of the AutoSize property changes.
Occurs when the value of the BackColor property changes.
Occurs when the value of the BackgroundImage property changes.
Occurs when the BackgroundImageLayout property changes.
Occurs when the value of the BindingContext property changes.
Occurs when the value of the CausesValidation property changes.
Occurs when the focus or keyboard user interface (UI) cues change.
Occurs when the control is clicked.
Occurs when the value of the ClientSize property changes.
Occurs when the value of the ContextMenu property changes.
Occurs when the value of the ContextMenuStrip property changes.
Occurs when a new control is added to the Control.ControlCollection.
Occurs when a control is removed from the Control.ControlCollection.
Occurs when the value of the Cursor property changes.
Occurs when the component is disposed by a call to the Dispose() method.
Occurs when the value of the Dock property changes.
Occurs when the user double-clicks the Button control.
Occurs when the DPI setting for a control is changed programmatically after the DPI of its parent control or form has changed.
Occurs when the DPI setting for a control is changed programmatically before a DPI change event for its parent control or form has occurred.
Occurs when a drag-and-drop operation is completed.
Occurs when an object is dragged into the control’s bounds.
Occurs when an object is dragged out of the control’s bounds.
Occurs when an object is dragged over the control’s bounds.
Occurs when the Enabled property value has changed.
Occurs when the control is entered.
Occurs when the Font property value changes.
Occurs when the ForeColor property value changes.
Occurs during a drag operation.
Occurs when the control receives focus.
Occurs when a handle is created for the control.
Occurs when the control’s handle is in the process of being destroyed.
Occurs when the user requests help for a control.
Occurs when the ImeMode property is changed. This event is not relevant for this class.
Occurs when a control’s display requires redrawing.
Occurs when a key is pressed while the control has focus.
Occurs when a character. space or backspace key is pressed while the control has focus.
Occurs when a key is released while the control has focus.
Occurs when a control should reposition its child controls.
Occurs when the input focus leaves the control.
Occurs when the Location property value has changed.
Occurs when the control loses focus.
Occurs when the control’s margin changes.
Occurs when the control loses mouse capture.
Occurs when the control is clicked by the mouse.
Occurs when the user double-clicks the Button control with the mouse.
Occurs when the control is double clicked by the mouse.
Occurs when the mouse pointer is over the control and a mouse button is pressed.
Occurs when the mouse pointer enters the control.
Occurs when the mouse pointer rests on the control.
Occurs when the mouse pointer leaves the control.
Occurs when the mouse pointer is moved over the control.
Occurs when the mouse pointer is over the control and a mouse button is released.
Occurs when the mouse wheel moves while the control has focus.
Occurs when the control is moved.
Occurs when the control’s padding changes.
Occurs when the control is redrawn.
Occurs when the Parent property value changes.
Occurs before the KeyDown event when a key is pressed while focus is on this control.
Occurs when AccessibleObject is providing help to accessibility applications.
Occurs during a drag-and-drop operation and enables the drag source to determine whether the drag-and-drop operation should be canceled.
Occurs when the value of the Region property changes.
Occurs when the control is resized.
Occurs when the RightToLeft property value changes.
Occurs when the Size property value changes.
Occurs when the control style changes.
Occurs when the system colors change.
Occurs when the TabIndex property value changes.
Occurs when the TabStop property value changes.
Occurs when the Text property value changes.
Occurs when the control is finished validating.
Occurs when the control is validating.
Occurs when the Visible property value changes.
