Windows forms group controls


















The appearance of the text is controlled by the Font property and the TextAlign property. The Button control can also display images using the Image and ImageList properties. The most basic use of a Windows Forms Button control is to run some code when the button is clicked. If you intend to attach event handlers for these related events, be sure that their actions do not conflict. For example, if clicking the button clears information that the user has typed in a text box, pausing the mouse pointer over the button should not display a tool tip with that now-nonexistent information.

If the user attempts to double-click the Button contr91, each click will be processed separately; that is, the control does not support the double-click event. How to respond to a button click. EventArgs e ,. The Windows Forms CheckBox control indicates whether a particular condition is on or off.

You can use, check box controls in groups to display multiple choices from which the user can select one or more. The check box control is similar to the radio button control in that each is used to indicate a selection that is made by the user. They differ in that only one radio button in a group can be selected at a time. A check box may be connected to elements in a database using simple data, binding.

Multiple check boxes may be grouped using the GroupBox control This is useful for visual appearance and also for user interface design, since grouped controls can be moved around together on the form designer. Checked property returns either true or false. The CheckState property returns either.

CheckState Checked or CheckState. In the indeterminate state, the box is displayed with a dimmed appearance to indicate the option is unavailable. You can program your application to perform some action depending- upon the state of the check box. For example, you may have a form representing personal information and the fields related to an address would be grouped together.

At design time, it's easy to move the group box around along with its contained controls. The group box supports the same manual and automatic placement styles that a form does. A group box also cuts off any portion of a control that falls out of bounds of the panel.

Unlike the panel control, a group box doesn't have the capability to scroll content and display scroll bars. The FlowLayoutPanel control arranges its contents in a horizontal or vertical flow direction.

You can wrap the control's contents from one row to the next, or from one column to the next. Alternately, you can clip instead of wrap its contents. You can specify the flow direction by setting the value of the FlowDirection property.

You can also specify whether the FlowLayoutPanel control's contents are wrapped or clipped by setting the value of the WrapContents property. The FlowLayoutPanel control automatically sizes to its contents when you set the AutoSize property to true. It also provides a FlowBreak property to its child controls. Setting the value of the FlowBreak property to true causes the FlowLayoutPanel control to stop laying out controls in the current flow direction and wrap to the next row or column.

The image above has two FlowLayoutPanel controls with the BorderStyle property set to demonstrate the bounds of the control.

The TableLayoutPanel control arranges its contents in a grid. Because the layout is done both at design time and run time, it can change dynamically as the application environment changes. This gives the controls in the panel the ability to resize proportionally, so they can respond to changes such as the parent control resizing or text length changing because of localization.

This allows you to construct sophisticated layouts that adapt to changes at run time. You can also control the direction of expansion horizontal or vertical after the TableLayoutPanel control is full of child controls. By default, the TableLayoutPanel control expands downward by adding rows.

You can control the size and style of the rows and columns by using the RowStyles and ColumnStyles properties. You can set the properties of rows or columns individually. The image above has a table with the CellBorderStyle property set to demonstrate the bounds of each cell. The Windows Forms SplitContainer control can be thought of as a composite control; it's two panels separated by a movable bar. When the mouse pointer is over the bar, the pointer changes shape to show that the bar is movable.

With the SplitContainer control, you can create complex user interfaces; often, a selection in one panel determines what objects are shown in the other panel. This arrangement is effective for displaying and browsing information. Having two panels lets you aggregate information in areas, and the bar, or "splitter," makes it easy for users to resize the panels. The image above has a split container to create a left and right pane.

The right pane contains a second split container with the Orientation set to Vertical. The BorderStyle property is set to demonstrate the bounds of each panel. The TabControl displays multiple tabs, like dividers in a notebook or labels in a set of folders in a filing cabinet.

The tabs can contain pictures and other controls. Use the tab control to produce the kind of multiple-page dialog box that appears many places in the Windows operating system, such as the Control Panel and Display Properties. Additionally, the TabControl can be used to create property pages, which are used to set a group of related properties. Chris Hayes Chris Hayes 3, 6 6 gold badges 36 36 silver badges 70 70 bronze badges.

Add a comment. Active Oldest Votes. You could subclass the text box control write your own that inherits a textbox Btw, i have thought about this and i would take another approach: i would override the text box's paint handler and when the textbox contains no information, draw an info string into it. Something like: using System; using System. Forms; using System. IsNullOrEmpty this. DrawString "My info string Font, System. Gray, new System.

DrawString Text, this. Font, new SolidBrush this. ForeColor , new System. Paul Sasik Paul Sasik If so, how can you map it to the textbox's font size and type. Chris: That's correct. You do it programmatically. You can query the text box's public properties and assign them directly to any other for example: MyLabel.

Font; — Paul Sasik. Chris: Check out the new code sample. It's simple and just a bit quirky but demonstrates the idea. The drawing quirk i mentioned is mitigated by setting the font on the control to Microsoft Sans Serif, 10pt, Bold It's Not every control responds to every event. For example, the Label control doesn't respond to keyboard input, so the Control. PreviewKeyDown event isn't raised. Most shared events fall under these categories:. For more information, see Control events and How to handle a control event.

Windows Forms has accessibility support for screen readers and voice input utilities for verbal commands. However, you must design your UI with accessibility in mind.

Windows Forms controls expose various properties to handle accessibility. For more information about these properties, see Providing Accessibility Information for Controls. Skip to main content.



0コメント

  • 1000 / 1000